By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,650 Members | 753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,650 IT Pros & Developers. It's quick & easy.

DGV editing on a row that is removed

P: 116

Could anyone let me know the etiquette/error-handling for the following situation?

I have a DGV with rows that are liable to be removed via a call to a third party data source. There is a possibility that a cell will be in the process of being edited when the row is removed. This tends to cause havoc with the EndEdit handler as it doesn't get called.

I have tried to deal with it by checking if the row about to be removed is the CurrentRow.Index and then forcing an EndEdit but this seems to cause other issues - possibly because the Index changes etc.

So - is there any proven method of safely losing a row without warning that has the cursor within it?

Thanks in advance.
Feb 20 '14 #1
Share this Question
Share on Google+
2 Replies

P: 299
I'm not exactly sure how your system is setup, but is it possible that you get a row count in your data source prior to "updating" the record? And if the row count doesn't match then just complete a DGV.Refresh() when trying to submit the change?
Feb 20 '14 #2

P: 116
Hi Luk3r,

Thanks for the reply. The DGV updates itself fine - there's just a possible conflict if editing starts on a cell and doesn't get finished before that row is removed. there's a procedure on EditStart and one on EditEnd but if the row disappears before the editing is complete the the EditEnd can't run.

All the best
Feb 20 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.