How to change commit value in dataGridView?

I have dataGridViewone that has a checkbox column. Whenever the user clicks on the checkbox, I use an event CellContentClickwhere I handle the necessary action.

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

+3
source share
1 answer

You might want to watch 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;
   }
}
+1
source

Source: https://habr.com/ru/post/1795746/


All Articles