How to cancel deletion of a row in DataGrid?
Hi all!
I have a Windows Forms app which shows some data in a DataGrid. Everything goes grreat but there's one major problem. I can't solve how to cancel a row delete in the DataGrid. I can cancel the deletion in the DataTable object by calling the RejectChanges() method but still if I call it (I have tested it on both DataTable.RowDeleting and DataTable.RowDeleted events) the delete is cancelled from the DataTable object nut not on the DataGrid object and the DataGrid object deletes the row from the view. Now I need to update my form by showing something else there and the changing back to the DataGrid view, then I can see again the previously deleted row. Is there any way to make the row stay on the DataGrid if the delete is cancelled? I already tried to update the DataGrid by populating it with new data in the DataTable.RowDeleted event but it raises this:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll.
What could I do?