We have an old WinForms app with a .NET Advantage 2009 UltraWinGrid control. The default sort column was specified in the Design view, but now we have a requirement to save the user's sort order and restore it when relaunching the app.
We can get the last sort order in the Form_Close event with:
var gridSort = _ourGrid.DisplayLayout.Bands[0].SortedColumns[0];SettingsFile.Save(gridSort.Key, (int)gridSort.SortIndicator);
And the correct values are stored in the Settings file, but nothing seems to restore the sort order to the grid. We have tried code like:
string columnName;SortIndicator columnSort;SettingsFile.Load(out columnName, out (int)columnSort);var ourGridSort = _ourGrid.DisplayLayout.Bands[0].SortedColumns;ourGridSort.Clear();ourGridSort.Add(columnName, columnSort);_ourGrid.DisplayLayout.Bands[0].SortedColumns.RefreshSort(true);
In the Form_Load, but this has no effect on the grid, it remains sorted by the original default.
You are correct; after the form was loaded another routine fills the grid then changes the sort to a hard-coded value.
This code looks correct to me. So my guess is that this is working and then something else in your code is blowing it away and restoring the old sorting. Maybe you are loading/saving the grid's DisplayLayout.