I am trying to change the column sorted programatically. When I click on a column at the top of the grid it sorts it and has little arrow glyph showing the direction. I want that glyph to move to the first column in my program when I reload the grid and I want that column to be sorted. I've tried all the SortSettings. Like StrGrd.SortSettings.Column := 0;. But it seems to have no effect when I reload the grid. It still sorts on the last column I had clicked on to sort, previously. I am using DXE8.
grid.SortSettings.Column sets the column to sort on
It doesn't seem to work for me. I do it after I have collected all the data. It stays sorted on the last column I clicked on for sorting. Is there any other porperties that have to be set? The only way I have been able to do it is destroy and create a new grid.
In my retesting, everything works as expected:
What about if you sort on a different column, by clicking on that column. Then set the sort in the program (SortSettings) back to column 1. Not clicking on the column, but doing it in the program?
That is exactly what I did in my tests and it works fine. I do in fact not see a reason why it wouldn't work.
I found the problem. It was saving the sort settings before the getting records and loading the grid settings after the records were loaded. So it was overriding my settings.