开发者

How to change the committing value in dataGridView?

I have a dataGridView that has a column with checkb开发者_如何学运维oxes. Whenever the user clicks on a checkbox I use the event CellContentClick where I process the necessary action.

But now, in some cases, I would like the value not to be committed (the checkbox to be unchecked). Any idea how to do this?


You might want to look at the CellValidating event. So something like this:

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;
   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜