I want to programatically add new row to a datagridview which is bound to a collection. When I do that I get an exception. (note: when user creates new row via datagridview (types something into new row) I have no problems).

Error that is thrown:System.InvalidOperationException was unhandled. Operation did not succeed because the program cannot commit or quit a cell value change.

I need to switch to a new row to ensure that user won't leave row in not validated state.

Is it possible to overcome this without disabling row validation?

Thank you for you answers.

EDIT: Bindingsource is populated with objects created by Entity Framework. When a user creates a new object, for instance "location", it is created with default values, which can't be saved to database, thus I need validation. I validate that all important fields are not empty (or filled with default values). If they are I cancel validation. I think you can easily recreate it with just a simple bindinglist of simple(one string field should be enough) objects bound to a datagridview. Then create a row validating event and validate using something similar.

Maybe a better approach would be to add your row to the DataGridView instead of the datasource and include default data that is not invalid. Similar to this: Add new row to DataGridView
–
Brad RemMar 20 '12 at 20:25

If possible can you give enough code in your question to duplicate the issue - in particular that code you use to populate the bindingsource and any code that is triggered on validation.
–
David HallMar 20 '12 at 21:39

I've managed to duplicate the error (adding in some validaiton code) but you might want to include your actual code in case other people can help. I'm still looking.
–
David HallMar 20 '12 at 21:51