FMX TStringGrid set selected cell

922 views Asked by At

I need to do a cell jump in an FMX TStringGrid. Before, I did it in a VCL application using this code:

StringGrid.Row := StringGrid.Row + 1;
StringGrid.Col := 1;

So, how do I do that in FMX?

2

There are 2 answers

0
Remy Lebeau On

The exact same code should work in FMX too, as FMX's TStringGrid has writable Row and Col properties, just like VCL's TStringGrid has.

0
Tom Brunberg On

If you tried the same code in FMX, you might have been misguided by the fact that FMX doesn't indicate the selection automatically. You need to set the focus to the grid to see which cell is selected:

StringGrid1.Row := StringGrid1.Row+1;
StringGrid1.Col := 1;
StringGrid1.SetFocus;

Alternatively you can select a cell also with

StringGrid1.SelectCell(1, 2); // col, row
StringGrid1.SetFocus;