The DBGrid Component

The DBGrid component is a workhorse among the data-aware controls Using a DBGrid, your application can display or manipulate a dataset in a familiar table-like form. The data is displayed and can be edited in an easily discernable rows-and-columns format. The columns represent the field definitions from the dataset with each row representing an individual record.

Without any modification to its properties, the appearance of data in . the DBGrid component is largely defined by the properties of the fields in the underlying dataset. By default, the headings for the columns and ; the order of their presentation matches those of the table. Changes to the properties in the dataset are immediately propagated to the grid. The grid does not display Field objects in the dataset whose Visible ; property is set to False.

The columns in the grid are dynamic and can be added, deleted, and rearranged at design or run time. The fact that must always be remembered is that the controlling properties for these columns do not belong to the grid itself but rather to the field objects contained in the dataset that the grid is composed of. Dynamic grid columns, for example, exist only so long as the field upon which they are based exists. When the dataset is closed, the column is destroyed.

Because the field objects determine the makeup of the DBGrid, the construction of the grid enjoys a great measure of flexibility. The same display grid in an application can display a local database table at one moment, then be completely redrawn seconds later to display the results of a query. The new dataset and its properties will immediately replace all of the properties of the former table. This change is as simple as pointing the DBGrid to a different DataSource control.

Was this article helpful?

0 0

Post a comment