Working with Checkbox column in DataGrid in Winforms project
I have a checkbox column, and it is开发者_StackOverflow working just as intended.
How do I "get" the selected rows ?
I'd like to get the ones that are checked and run a method using another field of the same row.
I believe the answer would look something like:
foreach (DataGridViewRow item in DataGridName.Rows)
{
if (((bool)(item.Cells["name_of_column"].Value)) == true)
{
MyMethod(item.Cells["name_od_the_other_field"].Value);
}
}
Solved it through:
foreach (DataGridViewRow item In DataGridName.Rows)
{
If (item.Cells(0).Value)
{
MyMethod(item.Cells(0).Value);
}
}
精彩评论