I am working on a DataGridView called ListingGrid , trying to activate / deactivate users who have been "tagged" on any DataGridViewCheckBoxCell that is inside the DataGridViewCheckBoxColumn .
This is exactly how I am trying to do this:
foreach (DataGridViewRow roow in ListingGrid.Rows) { if ((bool)roow.Cells[0].Value == true) { if (ListingGrid[3, roow.Index].Value.ToString() == "True") { aStudent = new Student(); aStudent.UserName = ListingGrid.Rows[roow.Index].Cells[2].Value.ToString(); aStudent.State = true; studentList.Add(aStudent); } } }
As far as I understand, when you check the DataGridViewCheckBoxCell , is the value of the true cell correct? But this does not allow me to convert the value to bool, and then compare it, throwing me an invalid exception.
source share