OnBeforeDrawCell

Class: TEgDBGridEx

property OnBeforeDrawCell: TEgDBGridBeforeDrawCellEvent;

Fired once per cell, for every column type, just before it is filled and painted, whenever assigned. Use Column.Field to identify the underlying field - nil for a Custom Cell column (empty FieldName). FontColor, BackColor, and Font arrive already resolved to what the cell would normally use (selection, VCL Style, and column colors already applied); change them to override. Font is the actual Canvas.Font about to be used, not a copy, so changing Name/Size/Style/Color on it takes effect directly.

CellText, ImageIndex, and ImageAlignment arrive pre-filled with whatever that column would show by default:

A checkbox cell ignores all three, since it always draws its own glyph.

CellText is passed through the same <var>VarID</var> placeholder resolution used elsewhere in the grid (see OnGetVariableValue) before being painted, for every column kind except Memo/CLOB - so a value this handler assigns to CellText can itself contain <var>FieldName</var> markers and have them resolved normally.

Replaces the older OnDrawCustomCell, which only covered Custom Cell columns and had no color/font control. Also available at column level (see TEgColumn.OnBeforeDrawCell); when both are assigned, the grid-level handler runs first. See TEgDBGridBeforeDrawCellEvent.

See Also

(C) 2026 Easygate, Lda