How to catch "new-row-editing-cancelled" event in DataGridView (isthere any similar event?)

  • Thread starter Thread starter Paul Jones
  • Start date Start date
P

Paul Jones

Hi,
I need to know when user cancelled adding a new row to the DataGridView.
Is there a way how to do it? I explored the DataGridView events but
failed to find any usable one.

The thing is I need to do something when user adds a row to the DGV.
This is done in the DGV_UserAddedRow. In case user starts filling one
cell in the NewRow row, UserAddedRow is fired. If he/she decides not to
add this row and cancels it by pressing ESC, the row disappears, but
code in the DGV_UserAddedRow was already executed and I need it to be
undone. How?

Thanks for any help.

With regards
Paul Jones
 
I need to know when user cancelled adding a new row to the
DataGridView.
Is there a way how to do it? I explored the DataGridView events but
failed to find any usable one.
The thing is I need to do something when user adds a row to the DGV.
This is done in the DGV_UserAddedRow. In case user starts filling one
cell in the NewRow row, UserAddedRow is fired. If he/she decides not
to add this row and cancels it by pressing ESC, the row disappears,
but code in the DGV_UserAddedRow was already executed and I need it to
be undone. How?

You may be able to check the DataGridView.CurrentRow.IsNewRow property and
deal with the bound values appropriately. If using an IBindingList implementation,
you may be able to just call .CancelEdit.
Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
Hi Jim,
thanks for your reply. I'm afraid this is not what I need. Changes made
in the DGV_UserAddedRow function do not include changes in the DGV.
That's why I need to catch this "new-row-editing-cancelled" to get all
those things to the previous state. Nevertheless, I'll try the
DataGridView.CurrentRow.IsNewRow in UserDeletedRow or RowsDeleted, maybe
it will work.

With regards
Paul Jones


Jim Wooley napsal(a):
 
Back
Top