DataGridView与CheckBox单元格问题 [英] DataGridView with CheckBox cell problem
问题描述
你可以听 CurrentCellDirtyStateChanged 事件和强制提交更改:
void dataGridView1_CurrentCellDirtyStateChanged(object sender,
EventArgs e)
{
if(dataGridView1.IsCurrentCellDirty)
{
dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
I have a DataGridView with a DataGridViewCheckBoxColumn column, which is databound to a list. The problem is that the databound boolean property for this checkbox is updated not when the check box is checked/unchecked, but after the CellLeave event in other words after the cell looses focus. I want this property to be updated right after the check/uncheck. There's an event CurrentCellDirtyStateChanged which is fired right after check/uncheck happens, so I can use it to update the propery manually. Is there a better way to do this?
You can listen for the CurrentCellDirtyStateChanged event and force Commit the change:
void dataGridView1_CurrentCellDirtyStateChanged(object sender,
EventArgs e)
{
if (dataGridView1.IsCurrentCellDirty)
{
dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
这篇关于DataGridView与CheckBox单元格问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!