The following tutorial walks you through creating a project and binding the Spread control to a database. These instructions are based on the steps required in Visual Studio 2013 or later.
The following steps will help you in adding Spread control to the project:
If you do not know how to add the FpSpread component to the project, refer to Adding a Component to a Visual Studio 2019 Project or Adding a Component to a Visual Studio 2015 or 2017 Project or Adding a Component to a Visual Studio 2013 Project.
In this section, we will use the Quickstart menu to set up the database connection and the data set.
You can also click the Test Connection button in the Add Connection dialog to test the connection. If you do not receive a message stating the "Test connection succeeded" retry this step. If you receive the message "Test connection succeeded," your connection is complete. Click OK to close the Add Connection dialog.
If your form doesn't look similar to the image shown above, adjust the size of your Spread control and re-check the steps that you have performed so far.
In this step, you can change the cell type for one of the columns to display the data from the database in a better way.
The following code snippet can be added to enhance the display of the data fetched from the database.
C# |
Copy Code
|
---|---|
// Bind the component to the data set. fpSpread1.Sheets[0].AutoGenerateColumns = false; fpSpread1.Sheets[0].DataSource = dbDataSet; fpSpread1.Sheets[0].ColumnCount = 2; fpSpread1.Sheets[0].BindDataColumn(0, "ID"); fpSpread1.Sheets[0].BindDataColumn(1, "Description"); |
VB |
Copy Code
|
---|---|
' Bind the component to the data set. fpSpread1.Sheets(0).AutoGenerateColumns = False fpSpread1.Sheets(0).DataSource = dbDataSet fpSpread1.Sheets(0).ColumnCount = 2 fpSpread1.Sheets(0).BindDataColumn(0, "ID") fpSpread1.Sheets(0).BindDataColumn(1, "Description") |