TTMSFMXGrid: prevent leaving a cell with invalid content

Dear Support,

Is it possible to prevent exiting a cell editor when its content is invalid? I tried the Allow var parameter in the grid's CellEditValidateData event handler, but it just discards the invalid content before exiting the cell.

Thank you very much for your input.

--
Best,
Carlos

Hi,

Yes you can something like this:

procedure TForm12.TMSFNCGrid1CellEditValidateData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TControl; var CellString: string;
  var Allow: Boolean);
begin
  Allow := False; //change to validation method
  if not Allow then
  begin
    TMSFNCGrid1.EditCell(MakeCell(ACol, ARow));
  end;
end;

Hi,

Thank you very much fr your prompt attention. I didn't work quite as I expected because the editing still completes, as the EditingDone event handler is still called after the validation handler exits. What I want is to the problematic value to be kept for further editing. Just for the sake of clarity I'm working with FMX UI Pack's grid, not FNC's.
Anyway this behavior is not crucial, and I've found, for the case in hand, another way to get the job done so I'll leave this alone for now.

--
Best,
Carlos

1 Like