How can i check for the bool condition of a check box which is in datagridview. I would like to have true if checked and false if it was unchecked. Can any one help me.
Is it possible to handle this in dataGridView_CellContentClick
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is addressed a little bit on the MSDN pages for the DataGridView here and here.
In particular they say:
So they recommend against using the CellClick type events (since they never push the value until you leave the cell) but instead use CurrentCellDirtyStateChanged and the CommitEdit method.
So you end up with:
And as for getting the checked value – this is just the Value property of the DataGridViewCheckBoxCell.
So if you go:
you get a boolean value which corresponds to the checkbox (after the change has been committed).