RAD Studio |  |

Associating a Data Control with a Dataset
See Also
Collapse All

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

1. Place a dataset in a data module (or on a form), and set its properties as appropriate.
2. 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.
3. Place a data control from the Data Access category of the Tool palette onto a form.
4. Using the Object Inspector, set the DataSource property of the control to the data source component you placed in step 2.
5. 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.
6. 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

- Changing the Associated Dataset at Runtime
- Enabling and Disabling the Data Source
- Responding to Changes Mediated by the Data Source

See Also

Editing and Updating Data

Disabling and Enabling Data Display

Refreshing Data Display

Enabling Mouse

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!