Class: TEgFireGrid
property OnBeforeDrawTitle: TEgFireGridBeforeDrawTitleEvent;
TEgFireGridBeforeDrawTitleEvent = procedure(Sender: TObject; Column: TEgFireGridColumn; var Text, SubTitle: string;
var ImageIndex: Integer; var ImageAlignment: TTextAlign; var FontColor, BackColor, SubTitleFontColor: TAlphaColor)
of object;
Occurs for a column’s title before it is shown, so the handler can
change it for that title only; Column is the title’s
column. Every other parameter arrives as the column resolves it and may
be changed:
| Parameter | Arrives as |
|---|---|
Text |
The title’s caption (DisplayCaption);
may contain <var> and <br>
markers. |
SubTitle |
The column’s SubTitle. |
ImageIndex, ImageAlignment |
The column’s TitleImageIndex
and TitleImageAlignment;
-1 = no icon. |
FontColor |
The title text colour in effect (the style’s, unless one is assigned and allowed). |
BackColor |
The column’s TitleColor,
TAlphaColors.Null for none. It is painted as a translucent
tint over the style’s title background, not as a solid colour. |
SubTitleFontColor |
The column’s SubTitleFontColor. |
The title’s font cannot be changed here: it belongs to the style’s
header (see TitleFont).
The grid’s handler runs first, then the column’s own event of the
same name. The event fires each time the titles are laid out again, not
at every repaint: when the columns change, when its column is resized,
and after a sort change, so a handler can reflect SortDirection.
A handler must not add, remove or hide columns.
procedure TForm1.Grid1BeforeDrawTitle(Sender: TObject; Column: TEgFireGridColumn; var Text, SubTitle: string;
var ImageIndex: Integer; var ImageAlignment: TTextAlign; var FontColor, BackColor, SubTitleFontColor: TAlphaColor);
begin
// The sorted column gets a light blue tint
if Column.SortDirection <> fgsNone then
BackColor := TAlphaColors.Lightskyblue;
end;