Can't Identify Values of DataGridViewCheckBoxCell

大兔子大兔子 提交于 2019-12-02 08:22:14

Maybe not the right solution for this problem in particular, but was useful for me in order to get the cell check value:

Use the event CellContentClick instead of CellClick. The first one triggers only when the check is correctly clicked, the second one triggers with a click in any part of the cell, which is a problem. Besides for any reason DataGridViewCheckBoxCell.EditedFormattedValue returns its value wrongly with CellClick, and we are going to use EditedFormattedValue.

Use this code:

DataGridViewCheckBoxCell currentCell = (DataGridViewCheckBoxCell)dataGridView.CurrentCell;
if ((bool)currentCell.EditedFormattedValue)
     //do sth
else
     //do sth
DataGridView.Rows[0].Cells[0].Value = true; 
or 
DataGridView.Rows[0].Cells[0].Value = false; 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!