How to select all rows in which something is seleccted? Say we have selected 10 items in all in difrent/same columns, in multiple rows like this:

And we want to get result similar to
var selected = ElementsTableView.SelectedRows.Cast<DataGridViewRow>();
yet for all rows in which is selected at least one column item. How to do such thing with WinForms in C#?
Try this:
var selected = ElementsTableView
.SelectedCells
.Cast<DataGridViewCell>()
.Select(c => c.OwningRow)
.Distinct();
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