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

# TDBGridColumns

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements a collection for columns in a database-aware grid.

## Declaration

Source position: dbgrids.pas line 298

`type TDBGridColumns = class(TGridColumns)`
`protected`
`procedure Update(); override;` |  | Redraws the Grid control that owns the column collection.
`function ColumnFromField();` |  | ColumnFromField returns the collection item for the specified Field.
`function HasAutomaticColumns;` |  | HasAutomaticColumns indicates if any items in the collection are an automatic column.
`function HasDesignColumns;` |  | HasDesignColumns indicates if the collection contains any items explicitly added at design-time.
`procedure RemoveAutoColumns;` |  | RemoveAutoColumns removes automatic columns in the collection.
`public`
`function Add;` |  | Add creates and stores a new item in the collection.
`function ColumnByFieldname();` |  | Gets the collection item with the specified field name.
`function ColumnByTitle();` |  | Gets the collection item with the specified column title.
`procedure LinkFields;` |  | Associates column items with the corresponding Fields in the Dataset.
`procedure ResetColumnsOrder();` |  | ResetColumnsOrder arranges columns in the collection to the specified order.
`property Items []: TColumn; default; [rw]` |  | Items provides indexed access to columns added to the collection.
`end;`

## Inheritance

`TDBGridColumns` |  | Implements a collection for columns in a database-aware grid.
`TGridColumns` |  | Collection used to store column definitions for a grid control.
`TCollection`
?
`TObject`

## Description

TDBGridColumns is a TGridColumns descendant which implements a collection for columns added to TDBGrid.

TDBGridColumns extends the ancestor class to include support for adding and removing automatic columns at run-time. Automatic columns are a feature in TDBGrid that, when enabled, ensures the collection has a column definition for each Field in the linked dataset for its grid control. Methods and Properties are provided to identify columns added at run-time, and to order entries in the collection by their design-time or run-time indices.

Items is the default property for the collection. TColumn is the class type used for Items added to the collection.

Use the Add method to create a new collection item in the Items property. Use LinkFields to update the association between an item in the collection and the TField used to access its data. Use ResetColumnsOrder to change the order of Items in the collection.

## See also

TDBGridColumns.Items |  | Items provides indexed access to columns added to the collection.
TDBGridColumns.Add |  | Add creates and stores a new item in the collection.
TDBGridColumns.LinkFields |  | Associates column items with the corresponding Fields in the Dataset.
TDBGridColumns.ResetColumnsOrder |  | ResetColumnsOrder arranges columns in the collection to the specified order.
TColumn |  | Implements a display column for the TDBGrid control.
TGridColumns |  | Collection used to store column definitions for a grid control.
TGridColumn |  | Implements a column definition used for tabular data in TCustomGrid.