I want to resort my grid when items in the datasource are changed (it's a bindinglist). Calling RefreshSort after I've made modifications works fine, but it seems that using RefreshSortPosition might be a more effective/performant call. However, I'm not sure how to determine the best way to get the affected rows. I don't want to make changes to support using RefreshSortPosition only to have those changes be more expensive than the gains I make by calling it. I thought I could wire to an event on the binding source or grid, but I didn't see an event that seemed appropriate.
Any best practice suggestions on this?
Hi,
RefreshSortPosition is for cases where you know that all of the rows are already sorted and you just need to refresh the position of a single row. So if you know you just added a new row to your data source, it would be more efficient to find that corresponding row in the grid (which would presumably be at the end of the rows collection) and refresh the sort position of that one row.
The same goes for a row where a value changed in a cell whose column is currently sorted.
RefreshSort re-sorts everything. So this is best to use only when you cannot determine the row(s) that may have changed.
In my case I don't know what rows I'm updating, I only know what objects in the binding source I'm updating.
I have one object which is manipulating the binding source and is ignorant of the presentation details, and another (the user control) which has wired up a grid to the binding source. I understand that I could wire up the user control to either the binding source or the grid, but I'm not sure which object/event is the most appropriate to use.