代码改变世界

在DataGridView中的CheckBox值变更后立即获取值。

2013-05-21 14:51  咒语  阅读(536)  评论(0编辑  收藏  举报
private void dgView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 8)
            {
                dgView.CommitEdit(DataGridViewDataErrorContexts.CurrentCellChange);
                var val = dgView["All", e.RowIndex].Value;
......

今天写到DataGridView里的CheckBox选中或取消时并不能立即获取值。查了下,加上红色标记的代码,立即提交变更。即可。