TEgDBGridEx

Class: TEgDBGridEx

Declared in: EgDBGridEx

TDBGrid descendant. Drop-in replacement for TDBGrid.
Every inherited members are still available, plus these new members:

Member Overview

Properties Methods Events
AlwaysAdjustRowHeight AdjustColumnWidth OnBeforeDrawCell
AutoColumnAll AdjustRowHeight OnCellDblClick
AutoColumnIndex CenterAllTitles OnCellImageClick
AutoColumnWidth ColumnByFieldName OnCellRightClick
AutoRowHeight ColumnByTitle OnCheckChange
AutoTitleHeight Create OnCornerImageClick
CellVAlign DefaultDrawColumnCell OnBeforeDrawTitle
CellWordWrap Destroy OnGetVariableValue
CheckBoxes ExportToXLSX OnGraphicError
CheckFrames GetGridCoord OnRowClick
CheckKind PointInCellRect OnSortChange
ClickableCursor PointToGridCoord OnTitleCellClick
ClicksOnRowSelect RestoreMinimumColumnWidths OnTitleCellRightClick
CornerImageAlignment SetColumnAlignments OnTitleImageClick
CornerImageIndex SetColumnFormats OnExportProgress
DelRowCaption SetColumnTitles
DelRowQuestion SetColumnWidths
DelRowsQuestion
DetectBlobImages
EditColor
ExtendedStrEditor
FixedCellStyle
FixedColor2
GridLineWidth
ImageOnSelectedOnly
Images
IndicatorWidthPx
MemoMaxChars
MinColumnWidth
MinFontSize
RowHeightPx
ScrollType
ShowImageOnEmpty
ShowImageOverGraphic
ShrinkFontToFit
SortDirection
SortFields
SortSelectedField
SortShowAll
TabOnEnter
TitleRowHeightPx
UseColorOnStyles
UseFixedColorOnStyles
UseFixedFontColorOnStyles
UseFontColorOnStyles

Usage

Checkbox, graphic, and memo columns

No setup is required: a boolean field is drawn as a checkbox automatically when CheckBoxes is True (the default), a graphic/BLOB field with recognizable image content (JPEG, PNG, Bitmap, Icon, GIF or Metafile) is drawn as a scaled image, and a memo/CLOB field is drawn as word-wrapped text, optionally truncated with MemoMaxChars for performance. Editing a memo/CLOB cell uses an extended in-place editor with line-break/multi-line support - see ExtendedStrEditor for the full behavior, which also extends to String columns when enabled. Format detection reads a fixed byte signature instead of trying each decoder in turn, so an unrecognized or corrupt BLOB no longer raises on every repaint. Setting DetectBlobImages also tries a plain (non-ftGraphic) BLOB field as an image. An image larger than its cell shrinks to fit, aspect ratio preserved. Transparency is respected for every format that carries it (PNG, GIF, Icon), including a 32-bit Bitmap with a genuine alpha channel; an ordinary opaque Bitmap (24-bit, or a 32-bit one whose alpha byte is unused) is unaffected. JPEG has no transparency of its own. GIF animation is not played - only the first/still frame is ever shown.

Because format detection reads each record’s own raw bytes independently, a single Graphic or BLOB column can freely mix formats from row to row - one record’s image can be a JPEG, the next a PNG, the next a GIF, and so on, with no need for every row to share the same format. With DetectBlobImages set, a plain BLOB column can go further still: some rows can hold a recognized image in any supported format while other rows in that very same column hold ordinary non-image binary data - each row is decoded on its own terms, so the two kinds of content can coexist in the same column without conflict.

Custom columns and per-cell overrides

Add a TColumn with an empty FieldName at design time, and implement OnBeforeDrawCell to supply the text and/or image shown in that column for the current row - useful for computed values, action icons, or status indicators that do not come directly from a field. The same event fires for every column type (not only custom ones), so it can also override a cell’s font color, background color, and font on a per-cell basis. Every column is actually a TEgColumn, which adds per-column overrides (image index/alignment, click events, and more) on top of the inherited TColumn.

Corner and title images

CornerImageIndex draws a fixed image in the corner cell above the indicator column (only meaningful with dgIndicator in Options), independent of any column, clickable via OnCornerImageClick - a plain addition, since the corner cell has no native click of its own. A column’s own TitleImageIndex is clickable via OnTitleImageClick, fired grid-wide and/or per column, in place of OnTitleCellClick for that one click.

A column’s own data-cell ImageIndex is similarly clickable via OnCellImageClick, fired instead of OnCellClick.
ImageOnSelectedOnly and ShowImageOnEmpty gate whether that image shows at all, and are both honored precisely by OnCellImageClick’s own hit-testing. On a graphic/BLOB column whose field content decoded into a real image, ImageIndex is fully suppressed by default - set ShowImageOverGraphic to draw it as an overlay on top of that image instead, at its normal ImageAlignment/CellVAlign position (no automatic placement adjustment to keep the two apart) - see ImageIndex for the full behavior. OnCellImageClick fires correctly for a click on this overlay icon too.

Right-click events

OnCellRightClick and OnTitleCellRightClick fire on a right-click landing on a data cell or a title cell respectively. OnTitleClick never fire for a right-click.

Clickable cursor

ClickableCursor shows a chosen cursor while hovering a data-cell checkbox or image that can actually be clicked - scoped to data cells only. The title row (sort arrow, title image) and the corner image always follow this same grid-level value directly; a column’s own ClickableCursor override never affects its title, only its data cells. The cursor never appears over a checkbox that cannot be toggled (ReadOnly at any level), nor over a checkbox or data-cell image that ClicksOnRowSelect says would be ignored under dgRowSelect.

ClicksOnRowSelect controls whether a data-cell ImageIndex icon click (OnCellImageClick) or a checkbox click still works while dgRowSelect is in Options - native dgRowSelect forces dgEditing out of Options unconditionally, which would otherwise silently block checkbox editing along with it. Both properties are overridable per column - see ClickableCursor and ClicksOnRowSelect.

Memo/CLOB and extended-editor columns

A Memo/CLOB column’s in-place editor always supports Ctrl+/Ctrl- font resizing, Enter inserting a line break instead of committing, Up/Down/ PgUp/PgDn navigating within the text before falling through to row/page navigation, and Ctrl+Tab inserting a literal Tab. Setting ExtendedStrEditor extends this same behavior to variable-length String columns (ftString/ftWideString), overridable per column via TEgColumn.ExtendedStrEditor. See ExtendedStrEditor for the complete behavior list.

Numeric column editing

Editing an integer, Float/Single/Extended, Currency, BCD, or FmtBCD field applies two automatic corrections:

Exporting to XLSX

ExportToXLSX writes the grid’s current data - every Visible column with a bound Field, in the grid’s own visual order - to a .xlsx workbook, with no third-party dependency. Field values are converted to native Excel types (numbers, dates, booleans, text) rather than formatted strings, so the result sorts and filters correctly once opened; text is escaped so embedded XML/HTML markup can never corrupt the file. A Custom Cell column (no Field) or a graphic/BLOB column is never exported, regardless of visibility. See ExportToXLSX for the complete parameter list and conversion rules. OnExportProgress fires during the export to report progress as a percentage, for a caller that wants to drive a progress bar or similar feedback.

Automatic sizing

Set AutoColumnWidth to let one column (AutoColumnIndex) or all columns (AutoColumnAll) absorb the difference between the total column width and the client area on every resize. Set AutoRowHeight and/or AutoTitleHeight to distribute any leftover client-area pixels evenly across the data rows, or add them to the title row instead, so no row is left partially cut off at the bottom regardless of the control’s own Height. AlwaysAdjustRowHeight controls whether this adjustment still runs when the dataset does not have enough records to fill the visible rows.

Sorting

Click a column title to sort by that field. SortFields controls which fields (and which directions) can be sorted this way; SortSelectedField and SortDirection reflect and control the current sort; OnSortChange fires whenever a title click actually changes either one. TEgDBGridEx only tracks and displays the sort state - applying it to the dataset (e.g. via an IndexFieldNames assignment or a re-query) is left to OnSortChange.

Delete confirmation

With dgConfirmDelete in Options (inherited from TDBGrid), pressing Ctrl+Delete shows a confirmation dialog built from DelRowQuestion / DelRowsQuestion (single vs. multi-row selection) and DelRowCaption. These three strings may embed <var>VarID</var> placeholders - see OnGetVariableValue for how VarID is resolved.

VCL Styles

With no custom VCL Style active, colors set through the grid’s/column’s own Color/Font.Color and EditColor always apply, everywhere - data cells, the title row, and the indicator column alike. With a custom style active, the style’s own colors are used for all of those instead, unless opted back out of, style active or not: UseColorOnStyles / UseFontColorOnStyles govern data cells, while UseFixedColorOnStyles / UseFixedFontColorOnStyles govern the title row and the indicator column - each pair is independent, so a grid can opt data cells out of theming while leaving the title row themed, or vice versa.

Note: DrawingStyle is redeclared with no read/write/default and does not appear in the Object Inspector. TEgDBGridEx paints almost all of its own cell content directly, bypassing the native gdsThemed/gdsClassic/ gdsGradient painting that DrawingStyle would otherwise select.

See Also

(C) 2026 Easygate, Lda