Eight worked examples, each built around one event or method and a
small, realistic scenario. Each shows complete handlers and explains the
parts that are easy to get wrong. They assume a form with a
TEgFireGrid named Grid1, bound through a
TDataSource to a FireDAC query Query1 of
products (fields such as Name, Category,
Price, Quantity, Stock,
Active, UpdatedAt, Photo), and an
image list ImageList1 assigned to the grid’s Images.
The code runs unchanged on Windows and Android, except where a note
says otherwise. Dialogs use FireMonkey’s TDialogService,
whose asynchronous form works on both platforms. Each example’s
Units section lists the units its code needs besides
the form’s own.
| Page | Event or method | Scenario |
|---|---|---|
| Example 1: Conditional formatting and a computed column | OnBeforeDrawCell |
Highlight negative prices; show a value computed from other fields in a column with no field |
| Example 2: A per-row action icon | OnCellImageClick |
A delete icon on every row, acting on its record |
| Example 3: Reacting to a check box toggle | OnCheckChange |
Refuse a toggle that breaks a rule, and keep a related field up to date |
| Example 4: Applying the sort to the dataset | OnSortChange |
Order a FireDAC dataset when a title is clicked |
| Example 5: Values that are not fields | OnGetVariableValue |
<var> markers in titles and cells answered by the
application |
| Example 6: Logging a bad graphic cell | OnGraphicError |
Report a picture that cannot be decoded |
| Example 7: Working with the multi-selection | SelectedRowIds |
Enable an action while rows are selected, then apply it to each selected record |
| Example 8: Exporting to Excel with progress | ExportToXLSX |
Export all rows or the selected ones, with a progress bar |