OnGetVariableValue

Class: TEgDBGridEx

property OnGetVariableValue: TEgDBGridGetVariableValue;

Fired while resolving a <var>VarID</var> placeholder in DelRowQuestion, DelRowsQuestion, DelRowCaption, a column’s title caption, or a data cell’s CellText (as set or left by OnBeforeDrawCell - every column kind except Memo/CLOB, see that event’s own page), whenever VarID does not match a field of the active dataset. The handler returns the placeholder’s replacement text in Value. If not assigned, an unresolved placeholder is replaced with an empty string. See TEgDBGridGetVariableValue.

How <var> placeholders are resolved

VarID is not required to be a field name - it is just an identifier. Each <var>VarID</var> occurrence in the source string is resolved independently, in this order:

  1. VarID is looked up as a field name in the active dataset (case-insensitive, via FindField).
  2. If a matching field is found, its string value (Field.AsString) is substituted.
  3. If no such field exists, OnGetVariableValue is called (when assigned) with VarID, and its returned Value is substituted instead - this is how a synthetic value with no matching field can be embedded (a running total, the logged-in user name, and so on).
  4. If neither resolves it, the placeholder is replaced with an empty string.

A malformed or unclosed <var> tag is left in the output as literal text.

In a title (a column’s title caption, or the CellText/SubTitleText left by OnBeforeDrawTitle), step 1 is skipped: <var>FieldName</var> is never looked up as an active dataset field, since a title paints once per column, not once per row - “the current record’s field” would be a meaningless, moving target there. Every <var> tag in a title goes straight to OnGetVariableValue (or an empty string if unassigned), exactly as if it named something that is not a field at all. Every other location (DelRowCaption/DelRowQuestion/ DelRowsQuestion, and a data cell’s CellText) still follows the full four-step resolution above.

The <br> line-break marker

A self-closing <br> tag (case-insensitive on the letters, no closing tag or content of its own) is replaced in place with a line break, anywhere <var> placeholders are resolved - a title caption or SubTitleText, a data cell’s CellText, or DelRowCaption/DelRowQuestion/ DelRowsQuestion. Unlike <var>, it names no field and needs no lookup - it is resolved directly, without ever calling OnGetVariableValue. Useful for forcing a line break in a string that would otherwise wrap (or not wrap) wherever the underlying field or static text happens to break.

See Also

(C) 2026 Easygate, Lda