0

My app is C# winform.

I saved my data in sql database with entity framework, but when I want to edit them the binding-source when user changes the data, but don't want to update the current object CancelEdit() doesn't work.

My binding-source datasorce is a table of entity framework.

My code when form loads:

myEntity contex = new myEntity();
myBindingSource.DataSource = contex.myTable;

And code for cancel button:

myBindingSource.CancelEdit();
Arman
  • 1,019
  • 2
  • 14
  • 33

1 Answers1

0

Try this:

Set each binding's DataSourceUpdateMode to OnValidation then set the containing form's AutoValidate property to Disable. This prevents binding as you change focus between controls on the form. Then in the Click event for the Cancel or Save button validate your form's input

read more: Manual data binding using WriteValue

Community
  • 1
  • 1
Julio
  • 1