C# 如何更改dataGridView中的提交值?
我有一个C# 如何更改dataGridView中的提交值?,c#,events,datagridview,C#,Events,Datagridview,我有一个dataGridView,其中有一列带有复选框。每当用户单击复选框时,我都会使用事件CellContentClick来处理必要的操作 但现在,在某些情况下,我希望不提交该值(复选框未选中)。你知道怎么做吗?你可能想看看这个活动。比如说: void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { object new_value = e.FormattedValu
dataGridView
,其中有一列带有复选框。每当用户单击复选框时,我都会使用事件CellContentClick
来处理必要的操作
但现在,在某些情况下,我希望不提交该值(复选框未选中)。你知道怎么做吗?你可能想看看这个活动。比如说:
void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
object new_value = e.FormattedValue;
// Do something
// If you dont like what you did, cancel the update
if(nope_didnt_like_it)
{
e.Cancel = true;
}
}