Question

I have a windows form application with DevExpress Xtragrid Suit. I have a screen that has a grid with many columns and rows, because of this i dont want to change the scroll position when i change or reload the data to the DataSource property.

Était-ce utile?

La solution

I presume you're only allowing one row to be selected at a time. That is,GridView.OptionsSelection.MultiSelect == false.

That being the case, you can handle the FocusedRowChanged event, and store information from that row (i.e, the value from a column or combination of columns that it unique within your data set) that will allow you to get back to it again. Then, when you need to update the data source, use the GridView.LocateByValue method to get the row handle of the row that had focus, and set the GridView.FocusedRowHandle to that row handle.

Note that you cannot simply save off the row handle before updating your data source, as row handles may change if you add or remove rows from the data source.

Autres conseils

I think you should stock your SelectedRowHandle and FocusedColumn somewhere. This link might help you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top