I know that to get single selected row on a datagridview using a BindingSource is this code:
BindingSource.Current
My questions is how to get the multiple current selected on datagridview using a BindingSource
Guess it might be too late, but here is one solution...
If the DataGridView is bounded to a BindingSource and/or a List of Object, you might retrieve a List of Object accordind to the selected rows this way:
var myListOfYOURBJECTTYPE = dataGridViewEstados.Rows
.Cast<DataGridViewRow>()
.Where(r => r.Selected == true)
.Select(d => (YOURBJECTTYPE)d.DataBoundItem)
ToList();
...or:
var myListOfYOURBJECTTYPE = dataGridViewEstados.SelectedRows
.Cast<DataGridViewRow>()
.Select(d => (YOURBJECTTYPE)d.DataBoundItem)
ToList();
You can't forget to configure your DataGridView SelectionMode to FullRowSelect!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With