Example 2: A per-row action icon

Uses OnCellImageClick to turn an icon shown on every row into an action button, here deleting the record, without a button column or any other control.

Scenario

A narrow column at the right shows a trash icon on each row. A click or tap on the icon asks for confirmation and deletes that record. A click elsewhere in the row behaves as usual.

Setup

Add a column with no FieldName and set it up in the Object Inspector or in code:

// FormCreate
ColDelete := Grid1.Columns.Add;
ColDelete.Title.Caption := '';
ColDelete.Width := 32;
ColDelete.ImageIndex := 1;                    // the trash icon in ImageList1
ColDelete.ImageAlignment := TTextAlign.Center;
ColDelete.ShowImageOnEmpty := True;           // the column has no text at all
ColDelete.Sortable := fscNone;
ColDelete.OnCellImageClick := ColDeleteImageClick;

Units

Besides EgFireGrid: System.UITypes (TTextAlign, TMsgDlgType, TMsgDlgBtn, mrYes), FMX.DialogService (TDialogService) and the unit of the dataset component (here FireDAC.Comp.Client, for Query1).

The handler

procedure TForm1.ColDeleteImageClick(Sender: TObject; Column: TEgFireGridColumn; RowIndex: Integer);
begin
  TDialogService.MessageDialog('Delete ' + Query1.FieldByName('Name').AsString + '?',
    TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbNo, 0,
    procedure(const AResult: TModalResult)
    begin
      if AResult = mrYes then
        Query1.Delete;
    end);
end;

Why it works this way

The titles and the corner have icons too: TitleImageIndex with OnTitleImageClick (a filter menu for the column, for instance) and CornerImageIndex with OnCornerImageClick (a menu of grid-wide actions). OnBeforeDrawCell can show the icon only on some rows.

See Also

(C) 2026 Easygate, Lda