Data controls connect to datasets by using a data source. A data source component (TDataSource) acts as a conduit between the control and a dataset containing data. Each data-aware control must be associated with a data source component to have data to display and manipulate. Similarly, all datasets must be associated with a data source component in order for their data to be displayed and manipulated in data-aware controls on a form.
Note: Data source components are also required for linking unnested datasets in master-detail relationships.
To associate a data control with a dataset
- Place a dataset in a data module (or on a form), and set its properties as appropriate.
- Place a data source in the same data module (or form). Using the Object Inspector, set its DataSet property to the dataset you placed in step 1.
- Place a data control from the Data Access category of the Tool palette onto a form.
- Using the Object Inspector, set the DataSource property of the control to the data source component you placed in step 2.
- Set the DataField property of the control to the name of a field to display, or select a field name from the drop-down list for the property. This step does not apply to TDBGrid, TDBCtrlGrid, and TDBNavigator because they access all available fields in the dataset.
- Set the Active property of the dataset to True to display data in the control.
For more information about managing the link between the data control and its dataset, see