Search code examples
c#winformshierarchyxtragrid

Restore focused row of DevExpress XtraGrid after RefreshDatasource


I'm using DevExpress XtraGrid.I have a list of objects as grid datasource, each object can contain (or not) a list of similar objects and so on. In this way I have kind of hierarchy. So grid for every inner list of objects creates a child view. When I add new object to datasource and call RefreshDatasource() grid completely collapses and I must again drill down through grid levels to my previously focused row.

Is there some way to restore focused row after datasource refresh to whatever sublevel of child views?


Solution

  • I think this article will give you a good start at succeeding in your challenge ;) It describes a way to preserve the view state of all (child) views in a XtraGrid with sample code.

    It's a whole bunch of code but you can easily copy / paste it to check it out and test it.