Cancelling a new row in an unbound datagridview

K

Kelllisa

When a user adds a row to an unbound datagridview, then clicks out of
the row (or the control loses focus for any reason) without entering
anything, I would like to have the row automatically deleted. However,
I cannot find an appropriate event to handle this case. Using
CellEndEdit results in a re-entry, and CellValidating/Validated and
most other events result in an InvalidOperationException.

Does anyone know where I could put this logic?

Thanks.
 
S

simida

Maybe grid's Leave event will help you.

In this event handler function, you can get all grid items and check
the last item whether it is empty.

Hope it works.

Sincerely,
simida


(e-mail address removed) 写é“:
 
K

K

That might help; although I will need to handle the case where the user
clicks or arrows to another row in the grid, and not out of the control
entirely. I will give it a shot.

Thanks for your help
 

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