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


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
 
Ad

Advertisements

J

Jim Wooley

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
 
Ad

Advertisements

P

Paul Jones

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):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top