Does anyone know how to unselect cell in a FireMonkey TStringgrid (in other words, i need to know which cell is selected and how to unselect)...?
We are using Delphi Berlin 10.1
Thanks in advance.
To get currently selected row, use Selected
property. To get currently selected column, use ColumnIndex
property. Row and column indices start at 0,
To unselect you can choose to set Selected
and ColumnIndex
to f. ex. -1.
Tested with this code:
procedure TForm29.Button1Click(Sender: TObject);
var
SelRow, SelCol: integer;
begin
SelRow := StringGrid1.Selected;
SelCol := StringGrid1.ColumnIndex;
Memo1.Lines.Add(Format('SelRow: %d, SelCol: %d',[SelRow, SelCol]));
StringGrid1.Selected := -1;
StringGrid1.ColumnIndex := -1;
SelRow := StringGrid1.Selected;
SelCol := StringGrid1.ColumnIndex;
Memo1.Lines.Add(Format('SelRow: %d, SelCol: %d',[SelRow, SelCol]));
end;
Selected
property gives the selected row index. TheColumnIndex
property gives the selected column. I cannot find a way to unselect other than selecting another cell. See Delphi XE4 stringgrid selectcell in FireMonkey – LU RD