DataGridView AddingNew – Refresh BindingSource?

Error:System.InvalidOperationException: Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.  From:


“You may be able to work around this by setting AllowUserToAddRows to false before calling RefreshBindings() and then set it to true after you’ve called RefreshBindings().In general, I’d recommend against re-binding in AddingNew. AddNew will create an instance of your type (if possible) and add it to your list. The way this was architected to work was that if your list was empty, AddNew (AddingNew) would get called. In AddingNew you should create a new instance of your type, possibly set default values, and then set e.NewObject to the new instance. In your case, you’re re-binding in AddingNew and not creating a new instance (which BindingSource will then do for you) which may cause additional problems. The design pattern is: Bind you Grid to the BindingSource
Bind your DataSource (list) to the BindingSource
If you DataSource is Empty, AddNew will get called (which fires AddingNew)
In AddingNew set e.NewObject to a new instance of your Type
BindingSource will then add this new instance to the DataSource (list)”


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: