There is no clear way to do this, because of the following:
You will not have the same instances of the objects binded to the grid and of course you will not have the same rows in the grid, but if you know the type of the objects in the grid, and if they have, let's say an identity column, then:
1. Before rebinding, save the selected data bound objects to a temporary list
2. Rebind the grid (having registered to the DataBindingComplete event)
3. OnDataBindingComplete if you have a temporary selected list, just parse the grid rows, and if the databound object is the same (based on a condition of course) just select that row.
Hope this is clear enough.
Hope this helps, if you have any other questions or comments, please let me know,
Telerik WinForms MVP
answered on 07 Jun 2011, 10:13 AM
Your scenario depends on the new DataSource you set. If it is different that the previous one, you should use a solution, simillar to the one suggested by Emanuel.
If you reset the DataSource with the same one, the following approach could be used:
Yes, in my case the datasource remained the same; although some properties of members within my datasource did change (this the need for refreshing the datasource). Anyway, I was able to store the unique ID of each member of my datasource in an array, refresh the datasource and then use a for loop to set the visible property of each item in the grid to true immediately after setting the datasource.