[转]DataGridView(winform)中,CheckBox未选中解决方法

在判断DataGridView中CheckBox选中列的时候,发现明明选中了CheckBox,但DataGridViewRow.Cells[0].FormattedValue值却为False.

解决方法:

1、在调用前提交操作,代码如下。然后使用FormattedValue取值。

//提交DataGridView修改的值
dgvWorkRecord.CommitEdit(DataGridViewDataErrorContexts.Commit);

2、直接使用EditedFormattedValue。

    FormattedValue是操作提交后的结果,而EditedFormattedValue是当前的结果,不管结果是否已经提交。

posted @ 2011-02-21 11:31  愤怒的熊猫  阅读(505)  评论(0编辑  收藏  举报