How to get checkbox cell's value of datagrid(WinForm) at runtime ?
C#
2
Posts
2
Posters
0
Views
1
Watching
-
Please help me. Thanks!
-
Please help me. Thanks!
int rowNumber = 3; int cellNumber = 2; bool b = (bool)dataGridView1.Rows[rowNumber].Cells[cellNumber].Value;
But one tricky thing is here: if a value you are getting was not set (nobody checks or unchecks this checkbox) the value of it is null. We need handle this case.int rowNumber = 3; int cellNumber = 2; bool b = false; if (dataGridView1.Rows[rowNumber].Cells[cellNumber].Value != null) { b = (bool)dataGridView1.Rows[rowNumber].Cells[cellNumber].Value; }