[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'DBGrids' (#lcl)

TCustomDBGrid.AddAutomaticColumns

Automatically adds a column definition for each Field in the dataset.

Declaration

Source position: dbgrids.pas line 420

protected procedure TCustomDBGrid.AddAutomaticColumns;

Description

AddAutomaticColumns is a procedure used to automatically add column definitions for each Field in the DataSet.

Please note that AddAutomaticColumns can be performed at run-time only; no actions are performed in the method at design-time.

AddAutomaticColumns requires an active dataset to access the Fields that must be added to the grid control. No actions are performed if the dataset in DataLink has not been assigned or marked as Active.

AddAutomaticColumns cannot be performed when GridStatus contains either gsRemovingAutoColumns or gsLoadingGrid. No actions are performed in the method when these values are included in the GridStatus property.

AddAutomaticColumns is enabled by including the value dgeAutoColumns in the OptionsExtra property. No actions are performed in the method when the feature has not been enabled in the OptionsExtra property.

AddAutomaticColumns uses DataLink to get the Fields for the dataset, and checks the Columns collection to see if a column already exists for each Field. If the Field is already in the collection, it is skipped to avoid duplicate Fields. Missing Fields are added to Columns using its Add method, and sets the IsAutomaticColumn and Visible properties to True for each. When missing Fields have been added, the ResetColumnsOrder method in Columns is called using the coFieldIndexOrder column ordering option.

AddAutomaticColumns updates the GridStatus property prior to adding columns to include the value gsAddingAutoColumns. The value is removed from GridStatus when adding columns has completed. This prevents the TDBGridColumns.Add method from removing automatic columns while the add operation is still active.

See RemoveAutomaticColumns and OptionsExtra for information about removing automatic columns in the Columns collection.

See also

TCustomDBGrid.GridStatus

  

Stores status information about operations active for the grid control.

TCustomDBGrid.OptionsExtra

  

Contains the extra options enabled for the database grid control.


Version 3.2 Generated 2024-02-25 Home