TTMSFMXGrid column order question


I need a way to locate TTMSFMXGrid columns that have been dragged with the mouse to a different position (dragging column one to another column position, etc).  My understanding of the Developers Guide suggests that grid->Columns->Index[col]->ID could be used to locate any column by ID.

I tried:
Grid->Columns->Items[1]->ID = "Column1";

I dragged column 1 with the mouse right several columns

Grid->Cells[1][0] changed as expected, showing the text previously written in old Column 2, now new Column 1.

Grid->Columns->Items[1]->ID is still "Column1"

I need help understanding the column index relationship between Columns->Items[1] and Cells[1][1] after changing column order.  Thanks for any enlightenment.

With grid.ColumnAtPosition you can get the index of the column at a given position in the grid.

This  basic sample should make this clear:

procedure TForm1.Button1Click(Sender: TObject);
  i: integer;
  i := TMSFMXGrid1.ColumnAtPosition(1);
  caption := i.ToString + ' - ' +TMSFMXGrid1.Columns.Name;

procedure TForm1.FormCreate(Sender: TObject);
  TMSFMXGrid1.Columns[1].Name:= 'ColA';
  TMSFMXGrid1.Columns[2].Name:= 'ColB';
  TMSFMXGrid1.Columns[3].Name:= 'ColC';
  TMSFMXGrid1.Columns[4].Name:= 'ColD';
  TMSFMXGrid1.Options.Mouse.ColumnDragging := true;

Drag a column to position 1 in the grid and then you can see what column is at position 1.

Thanks Bruno.  That's what I was missing.