I try to select or click a cell externally.
When I use tStringGrid.Col and tStringGrid.Row to select a cell, onSelectCell event runs twice.
How can I make it to be processed once?
If I use tStringGridSelectCell event to avoid the problem, a selection rectangle doesn't move to the position.
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormClick(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
private
TestCount: Integer;
end;
procedure TForm1.FormClick(Sender: TObject);
var
_Boolean: Boolean;
begin
StringGrid1.Col := 2;
StringGrid1.Row := 2;
// StringGrid1SelectCell(Self, 2, 2, _Boolean); // the event runs once well but the cell is not visible when the position is out of sight.
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
begin
// something to be implemented
Inc(TestCount);
Caption := IntToStr(TestCount); // testcount is 2
end;