Thursday, September 3, 2009

How to check the value of a DataGridViewCheckBoxCell

I was trying to get the value of a DataGridViewCheckBoxColumn in order to see if the checkbox is checked or not. But I was getting a null value everytime. After scratching my head for a while and some googling I found that I needed to invoke the CommitEdit method to get the value of the checkbox state.

So
this.dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString(); 
did the trick.

No comments:

Post a Comment