Force and Edited Cell to keep focus if not valid

You can block the mouse to move the focused cell by implementing OnSelectCell.

Example:


Add at form level a variable lastval to store the last validation result.

procedure TForm3.AdvStringGrid1CellValidate(Sender: TObject; ACol,
  ARow: Integer; var Value: string; var Valid: Boolean);
begin
  if Length(Value) > 2 then
    valid := false;
  lastval := valid;
end;

procedure TForm3.AdvStringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
begin
  CanSelect := lastval;
  if not lastval then
    AdvStringGrid1.ShowInplaceEdit;
end;