1. Home
  2. Computing & Technology
  3. Delphi Programming

Data Browsing and Navigation in Delphi Database Applications

By Zarko Gajic, About.com

5 of 6

Fields: a Collection of TField objects; Invoking the Fields Editor

The TDBGrid component is generally used when you want to present the entire recordset to the user (data in a table).

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:

  1. Invoke the Fields Editor by double clicking on the ADOTable1 component.
  2. Select the Name field, for example. Let the second tab of the Page control be the selected one.
  3. Drag the Name field on the form (precisely: TabSheet1).
When you drop the Name field on the tab sheet, Delphi places one TLabel and one TDBEdit component on it. The Caption of the Label component is the same as the DisplayLabel property of the dragged field. The DBEdit component is linked to the dataset's datasource through it's DataSource property.

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.

Index: Data Browsing and Navigation in Delphi Database Applications

  1. What Delphi Components and Controls are Needed for Data Access
  2. Data Controls; Data Source; Datasets
  3. ADO Connection (TADOConnection)
  4. Defining the User Interface
  5. Fields: a Collection of TField objects; Invoking the Fields Editor
  6. Let There Be Data Editing Delphi Form

5 of 6

Explore Delphi Programming

More from About.com

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Build Database Applications
  5. Data Browsing and Navigation in Delphi Database Applications - Fields Editor

©2008 About.com, a part of The New York Times Company.

All rights reserved.