Kostya
Kostya

Reputation: 141

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?

Upvotes: 1

Views: 2345

Answers (2)

Youp Bernoulli
Youp Bernoulli

Reputation: 5655

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.

Upvotes: 1

binarymnl
binarymnl

Reputation: 153

Here you need to maintain focused row before adding/inserting new object in existing grid data & refresh operation. Once you done with grid data update operation you can set earlier focused object by setting focused row handle. To obtain current row handle in case of MasterDetail grid you should follow link below: How to get a parent record/row handle in the master/detail grid

Upvotes: 1

Related Questions