Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
Rebuild DataSource but keep selection (and other properties) intact?? How to do that?
posted

With MS Grid (DataGridView) I can have few cells selected... Then do:

BeginInit

dataGridView.DataSource = some data table

EndInit

 

And then it will refresh the cells on the grid but the selection will remain as it was.

 

With infragistics it is not possible.... If i try to set the datasource while I'm in BeginInit and then I do EndInit then the grid is not being updated no matter what I do.

I also tried to do SuspendLayout change the values in the datasource and then resumelayout, but then I look the cells selection.

 

Any other way around, or a better way to do that I want to do?

 

Thanks

Parents
  • 469350
    Verified Answer
    Offline posted

    BeginInit and EndInit are intended for use by the Visual Studio design environment. You really should never call these methods in your code.

    If you have some selected cells in the grid and you change the grid's data source, the cells that were selected no longer exist. Those were cells that existed in the previous data source. The new data source has a completely new set of rows and cells, so there's no way to the grid can maintain the selection.

    You could store the indices of the selected rows and cells yourself and then re-apply them after changing the DataSource.

Reply Children
No Data