Coordinating Multiple selected rows in multiple DataGridView
Posted on 2011-10-25
I have 3 DataGridView's which each reference a BindingSource that references a DataTable in a DataSet. Each of the DataGridViews's displays a different set of the columns in the DataTable. The BindingSource correctly coordinates the data shown in each DataGridView nicely, as expected. The BindingSource also coordinates the CurrentRow to be the same in each DataGridView. Very nice, as expected. However, as we know, the CurrentRow is not necessarily a selected row. Furthermore, while we can have only one current row, we can have multiple selected rows. I would like to set up my application so that each DataGridView will always show the same set of selected rows. I know about the DataGridExposed members for SelectedRows, Selection Changed events. I know I can make a row selected with the DataGridViewRow.Selected = true. I have tried some programatic control of the Selected Rows, but because of the common BindingSource I get a lot of recursive events and the entire process soon gets quite messy and I just can't seem to get it to work right. Any suggestions on how to approach this would be appreciated.