Get the Index of ordered columns in TTMSFMXGrid

If the user sort the columns how can I get the index of the column by name or ID? if you do TTMSFMXGrid .Columns.ByID ('Id'). Index
or
TTMSFMXGrid .Columns.ColumnByName('Id'). Index
the index always get the column before the user has changed the order of columns.


thank

We traced & solved an issue with this.
With the next update, you'll be able to do this with:


TMSFMXGrid1.ColumnPosition(TMSFMXGrid1.Columns.ColumnByID('AColumnName').Index)


thanks for the help

Hello!
When the next update is available?

Thank you.

Hi, 


We are currently working on a major update, so it is unclear when the next update will be available. 
We hope to release the next version as soon as possible.

Kind Regards, 
Pieter

I somehow do this while the update does not come out? TMSFMXGrid1.ColumnPosition (TMSFMXGrid1.Columns.ColumnByID ('AColumnName'). Index)

No, There is currently no workaround for this. The next update will address this.


Kind Regards, 
Pieter
Hello!
I upgraded to the new version and still not working:
TTMSFMXGrid.ColumnPosition (TTMSFMXGrid.Columns.ColumnByID (AColumnName). Index)
This has not been resolved in this version?

I have retested this here with the latest version of the grid and I cannot reproduce this.

This was retested with a default grid on the form. Column ID's were set to 'A','B',...'E' and column dragging was enabled.
Using:
tmsfmxgrid1.ColumnPosition(tmsfmxgrid1.Columns.ColumnByID('B').Index));
always returns the correct position of column 'B' here.
Sorry to insist, but still does not work.
Following your example works fine even change the order of columns.
After you move the column to another position
i: = TMSFMXGrid2.Columns.ColumnByID ('B') Index;.
returns the correct value but
TMSFMXGrid2.ColumnPosition (i);
is not returning the current column position.
So if you try:
ShowMessage(TMSFMXGrid2.cells[TMSFMXGrid2.ColumnPosition(tmsfmxgrid1.Columns.ColumnByID('B').Index)+1,TMSFMXGrid2.Selected]);
to fetch the value of the selected cell in the 'B' column line will see that something is wrong.

Again, I cannot reproduce this.

Full test code on a default grid & TListbox on the form:




procedure TForm5.Button1Click(Sender: TObject);
var
  cp: integer;
begin
   cp := tmsfmxgrid1.ColumnPosition(tmsfmxgrid1.Columns.ColumnByID('B').Index);
   listbox1.items.Add(inttostr(cp));
   listbox1.Items.Add(TMSFMXGrid1.Cells[cp,1])
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  TMSFMXGrid1.LinearFill(false);
  TMSFMXGrid1.Options.Mouse.ColumnDragging := true;
  TMSFMXGrid1.Columns[0].ID := 'A';
  TMSFMXGrid1.Columns[1].ID := 'B';
  TMSFMXGrid1.Columns[2].ID := 'C';
  TMSFMXGrid1.Columns[3].ID := 'C';
  TMSFMXGrid1.Columns[4].ID := 'D';
end;

No matter where I move column B, the position & cell value in it is retrieved correct.

Okay.
I saw where my error.
I have a grid with Livebindings.
In Livebindings Designer I see the grid with:
"Column [0]" connected with BindSource field "ID"
This field appears on the grid in position 1 (Column [1]) because I have a fixed column.
Why is the Grid.Columns.Name and
Grid.Columns.Id are not set automatically when the bindings do?
When I change the column header in the designer that is changed is the header of the previous column :)