Perhaps I should start a new topic, but this context is quite precise.
I'm sure, I found the solution. When analyzing the unit grids, one can see, that the behavior of the small green triangle depends on the internal variable FSortColumn. FSortColumn is the number of the column actually sorted, it is -1 if not sorted. Unfortunately the property SortColumn is not writable. I made a check with a copy of the grids unit and modified the property SortColumn as readable AND writable. That's it.
If you set SortColumn to a value of greater or equal 0, the triangle appears, if set to -1, the triangle disappears; changing SortOrder changes the triangle up or down.
The header click routine sets the value of FSortColumn to the column number the user clicked; unfortunately the procedure SortColRow doesn't do so. Therefore the triangle does not appear, when you call SortColRow without clicking into the column header.
I think, it could be a good idea to make few modifications to TCustomGrid:
- property SortOrder: add a setting routine SetSortOrder, which invalidates the grid after setting the value
- property SortColumn: add a setting routine SetSortColumn, which checks the column number and invalidates the grid after setting the value
- Modify SortColRow: add a line FSortColumn := index;