Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restoring Previous cell value in c# datagridview

I want to restore the previous value of a cell of a DataGridView. I am currently using the ESC button but I do not want to use it. How can I achieve this?

if (string.IsNullOrEmpty(e.FormattedValue.ToString()))

If this condition is true, I want to re-assign the previou value of the cell and keep control in cell itself. The above code is executed on CellValidating event.

like image 739
Shaivya Sharma Avatar asked Feb 22 '26 17:02

Shaivya Sharma


1 Answers

Try this:

if (string.IsNullOrEmpty(e.FormattedValue.ToString()))
{
     dataGridView1.CancelEdit();
}
like image 139
etaiso Avatar answered Feb 25 '26 05:02

etaiso