I have a grid with the columns EventType, SortOrder, AccountId, Description. I have grouped by the Column EventType adding this column to the SortedColumns-Collection. I also have set a filter on the underlying binding source and a sort string (sorted by EventType, SortOrder, Description). If the grid comes up, everything looks nice.
Now I have two Buttons on my form, one to move the active row up, one to move down. I get the active row and the appropriate sibling row and swap the SortOrder-value of the two involved rows. After that I call RefreshSortPosition. Nothing happens. The rows does not change their indexes.
I also have tried to reassign the bindingSource sort criteria. Nothinh happens. Rows are displayed at the old position.
What I'm doing wrong here? Thanks for any help.
Thanks for answer MIke.
I change the SortOrder on the grid row. You're right I have to call Update because the changes are not saved to the SortOrder data row (just for one of the two row). I have 'swapped' the ActiveRow between the two rows and both changes are saved. But Update that is the right way to solve this.
Thanks.
Markus
Hi,
You should not have to sort on the BindingSource, the grid's sorting is independent of the list.
RefreshSortPosition on the row should work, assuming that you are calling it on the correct row and that you are calling the method after the data change has been committed to that row.
Are you changing the SortOrder field in the data source or on the grid row? If it's on the grid row, then you probably need to call Update on the row to commit the changes before you call RefreshSort.
If none of that works, another thing you could try it calling band.SortedColumns.RefreshSort - but that might have some undesirable effects, like collapsing the GroupByRows.
I maybe have found the problem by myself:
I added all the columns specified in the sort property of the bindingsource also to the SortedColumnsCollection of the grid.
This seems to be a rule (?) I did not know so far.
Anyway it seems to be working.