Home > Enterprise >  FMX TStringGrid set selected cell
FMX TStringGrid set selected cell

Time:12-04

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?

CodePudding user response:

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.

CodePudding user response:

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;
  • Related