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:
thanks for the help
When the next update is available?
Thank you.
Hi,
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.
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.
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:
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 :)