VSFlexGrid Introduction > Data Binding (ADO and DAO) > Other types of Data Binding > Binding to a FlexDataSource |
For the ultimate in data-binding flexibility, the VSFlexGrid control allows you to create your own data source objects and assign them to the VSFlexGrid control, which will display the data and allow the user to interact with it.
The main advantages of data-binding through the FlexDataSource property are speed and flexibility. You should consider using the FlexDataSource property when you have large amounts of data stored in custom structures or objects (other than database recordsets). By using the FlexDataSource property, you may display and edit the data in-place. There is no need to copy it to the grid and save it back later. In fact, the data may even be mostly virtual, consisting of dynamically calculated values rather than static information. Plus, you have complete flexibility to format and filter the data in any way you want.
To qualify as a FlexDataSource, your object must implement the IVSFlexDataSource interface. This interface consists of five simple methods:
Method Name |
Description |
---|---|
GetFieldCount() |
Returns the number of fields in the data source. |
GetRecordCount() |
Returns the number of records in the data source. |
GetFieldName(Fld&) |
Returns the name of field number Fld (ranging from zero to GetFieldCount() - 1). |
GetData(Fld&, Rec&) |
Returns the data in field Fld , record Rec (ranging from zero to GetRecordCount() - 1). |
SetData(Fld&, Rec&, Data$) |
Returns the data in field Fld , record Rec. |
For more details and a sample implementation of a custom data source, refer to the FlexDataSource property in the control reference section.