TcxGridDBColumn Class
A column in a data-aware grid Table View.
Declaration
TcxGridDBColumn = class(
TcxGridColumn
)
Remarks
A column in a data-aware Table View is designed to display values from a dataset field. Use the DataBinding property to bind a data-aware column to data.
In-Place Editors
A column can use any editor shipped with the ExpressEditors Library as an in-place editor for cell edit operations. An in-place editor instance exists (and, therefore, consumes memory and other system resources, such as a WinAPI handle) only when a column cell is being edited. Otherwise, the column displays a static editor image for resource usage optimization.
To switch between available editors, you can use the PropertiesClassName or PropertiesClass property. Use the Properties property to configure the in-place editor associated with the column.
Default In-Place Editor and Data Types
When PropertiesClassName and PropertiesClass properties are unspecified, the data type of the underlying dataset field determines the active in-place editor according to the following table:
Dataset Field Type | Default In-Place Editor | Description |
---|---|---|
ftBoolean |
TcxCheckBox | A check box editor with support for three states. |
ftCurrency , ftBCD , and ftFMTBcd |
TcxCurrencyEdit | A numeric editor for currency values. |
ftDate and ftDateTime |
TcxDateEdit | A date editor with a drop-down calendar. |
ftTime |
TcxTimeEdit | A spin editor for time values. |
ftBytes , ftVarBytes , ftBlob , ftFmtMemo , ftParadoxOle , ftDBaseOle , and ftTypedBinary |
TcxBlobEdit | A Binary Large Object (BLOB) editor. |
ftMemo |
TcxMemo | A multi-line editor for plain text. |
ftGraphic |
TcxImage | An editor designed to display images. |
All other types | TcxMaskEdit | A single-line text editor with support for input masks. |
Main API Members
The list below outlines key members of the TcxGridDBColumn
class that allow you to configure columns in a data-aware grid Table View.
- Bind the column to data (DataBinding).
- Fix the column or dock it to the left when users scroll the grid’s Table View to the right (FixedKind).
- Identify if the column is selected (Selected).
- Specify a caption for the column (Caption).
- Define an alternative caption for the column (AlternateCaption.
- Identify if the column is the first or last visible column in the parent grid View (IsFirst and IsLast).
- Hide or display the column (Visible).
- Switch between available in-place editor types (PropertiesClass and PropertiesClassName).
- Configure the assigned in-place editor (Properties and RepositoryItem).
- Activate and deactivate the assigned in-place cell editor (Editing).
- Adjust the column width to display content in full (ApplyBestFit).
- Sort data against the column (SortIndex and SortOrder).
- Group columns in the grid Table View (GroupIndex).
- Scroll the grid Table View to display the column (MakeVisible).
- Display custom cell value display text (OnGetDisplayText).
- Configure column summaries (Summary).
- Customize the appearance of column elements (Styles).
- Position column footer cells (FooterAlignmentHorz).
- Specify if the column is visible in an in-place Edit Form and the custom row layout (VisibleForEditForm and VisibleForRowLayout).
- Access the layout item that hosts the column’s editor in an in-place Edit Form (LayoutItem).
- Identify the column’s position in the parent grid View or a band (IsBottom, IsLeft, IsMostBottom, IsMostLeft, IsMostRight, IsRight, and IsTop).
- Assign a glyph to the column’s header (HeaderGlyph and HeaderImageIndex).
- Customize column appearance and behavior settings (Options).
- Position the glyph within the column header (HeaderGlyphAlignmentHorz and HeaderGlyphAlignmentVert).
- Configure the column’s container item in a custom row layout (RowLayoutItem).
- Identify if the column has a preview section (IsPreview).
- Access the grid Table View to which the column belongs (GridView).
- Custom draw the column (OnCustomDrawCell).
- Apply styles to different column elements (Styles.
- Adjust the minimum column width (MinWidth).
- Customize column captions displayed in a filter drop-down window (OnGetFilterDisplayText).
- Position the column header horizontally and vertically (HeaderAlignmentHorz and HeaderAlignmentVert.
Example: Create a Data-Aware Column
The following code example creates a data-aware column, associates it with a field in the dataset bound to the parent grid Table View, sets a single-line text editor as the column’s in-place editor, and customizes editor settings:
uses cxTextEdit;
// ...
var
AColumn: TcxGridDBColumn;
ATextEditProperties: TcxTextEditProperties;
begin
AColumn := cxGrid1DBTableView1.CreateColumn; // Creates a new data-aware column
AColumn.DataBinding.FieldName := 'ContactName'; // Binds the created column to the "ContactName" field
AColumn.PropertiesClass := TcxTextEditProperties; // Assigns an in-place single-line text editor
ATextEditProperties := AColumn.Properties as TcxTextEditProperties;
ATextEditProperties.Nullstring := 'Add a contact name'; // Prompts users to enter a contact name
ATextEditProperties.UseNullString := True; // Displays the defined text hint in an empty editor
ATextEditProperties.MaxLength := 30; // Limits the maximum contact name length
end;
Direct TcxGridDBColumn Class References
The following public API members reference a TcxGridDBColumn
object:
- TcxGridDBTableView.Columns
- Provides indexed access to the collection of the View’s columns.
- TcxGridDBTableView.CreateColumn
- Creates and adds a column to the View’s Columns collection.
- TcxGridDBTableView.GetColumnByFieldName
- Locates the column displaying a particular field’s values.