Working with a Checkbox column in a DataGrid project in Winforms

I have a checkbox column and it works as intended.

How do I β€œget” selected rows?

I would like to get the ones that were checked and run the method using a different field on the same line.

+4
source share
2 answers

I solved it through:

foreach (DataGridViewRow item In DataGridName.Rows) { If (item.Cells(0).Value) { MyMethod(item.Cells(0).Value); } } 
+2
source

I believe the answer will look something like this:

 foreach (DataGridViewRow item in DataGridName.Rows) { if (((bool)(item.Cells["name_of_column"].Value)) == true) { MyMethod(item.Cells["name_od_the_other_field"].Value); } } 
+7
source

Source: https://habr.com/ru/post/1310501/


All Articles