It depends what exactly you are doing when you "refresh" the grid. It sounds like whatever you are doing is causing your DataSource to send a Reset notification. That means that the data has been completely recreated. So the grid throws away all rows and columns and re-creates everything from scratch - so the rows cannot maintain their original state like selection or expansion.
The best thing to do is not cause a reset notification. There may be a better way for you to update your data.
The alternative would be for you to store the states of each row yourself. You can't store the row object itself, because once the reset occurs, the old rows are thrown away and new ones are created. So you would have to store the expanded state of each row based on the data in that row - perhap using the primary key.
You should not have to do anything. There are lots of different notifications that the DataSource can send. A Reset indicates a major structural change so the grid will completely throw away everything and recreate all new columns and rows. But if you add or modify a row, then the data source can notify the grid of these specific cases and the grid will update it's display without resetting everything.
If, for some reason, you do need to update the grid manually, you would probably want to use grid.Rows.Refresh(ReloadData).
A sample of what, exactly? I gave you the line of code that will refresh the grid data.
You mean a sample of using the UltraDataSource as an intermediary? The closest thing is the Million Rows sample which uses the UltraDataSource to display a grid with a million rows.
I have a similar issue with the Grid (v7.2.20072.61), though in my scenario the grid does not Collapse, it Expands (i.e. I see many rows across all group-levels).
When the grid is grouped by, say, a column named "Category", and a new row which belongs to a previously unreferenced "Category" is added to the bound UltraDataSource I would expect to see the new grid row created in a new group for that "Category" (which I do see) but I would not expect each and every existing group to be fully "Expanded" as this happens. I presume this relates to some kind of Rebuild / Reset notification (which you aluded to earlier), causing the entire set of data to be re-rendered.
Regardless, is there any way of suppressing or controlling this behaviour so the grid retains it's visual state during this operation? Alternatively, is there an event I can subscribe so I know when the "Reset" operation is happening and can attempt to address this in my own code?
Many thanksAl
I had the same problem, then I realized that I had saved the state as GroupByRowInitialExpansionState.Expanded in the form layout. Double check and see if you are not doing something similar.