Even though we can use the DBGrid to let the user add, edit and delete records from the database table - a better approach is to use Field objects for all the fields in a table. Field objects are mostly used to control the display and editing of data in your applications.
By using the Fields Editor you can set the list of persistent field object for every column in a table. The Field Editor is invoked by double clicking the DataSet component (ADOTable1). To add fields to the list of persistent fields for a dataset right-click the list and choose Add Fields.
Rather than presenting all the data in the table to the user (with the DBGrid), we might want to use field-oriented data aware components, such as edit boxes. The TDBEdit component for example, is a data-aware version of the TEdit class.
The easiest way to place a TDBEdit on the form and connect it with a field in the table is to:
- Invoke the Fields Editor by double clicking on the ADOTable1 component.
- Select the Name field, for example. Let the second tab of the Page control be the selected one.
- Drag the Name field on the form (precisely: TabSheet1).
If you select more than one filed from the Fields Editor and drag it on the form, Delphi will set as much Label/DBEdit components as you have dropped on the form. Note: if the table column is a "yes/no" column, allowing true/false values, Delphi will add a TDBCheckBox control.