How to: Commit In-Process Edits on Data-Bound Controls Before Saving Data
When editing values in data-bound controls, users must navigate off the current record to commit the updated value to the underlying data source that the control is bound to. When you drag items from the Data Sources Window onto a form, the first item that you drop generates code into the save button click event of the BindingNavigator. This code calls the EndEdit method of the BindingSource. Therefore, the call to the EndEdit method is generated only for the first BindingSource that is added to the form.
The EndEdit call commits any changes that are in process in any data-bound controls that are currently being edited. Therefore, if a data-bound control still has focus and you click the Save button, all pending edits in that control are committed before the actual save (the TableAdapterManager.UpdateAll method).
You can configure your application to automatically commit changes, even if a user tries to save data without committing the changes, as part of the save process.
The designer adds the BindingSource.EndEdit code only for the first item dropped onto a form. Therefore, you have to add a line of code to call the EndEdit method for each BindingSource on the form. You can manually add a line of code to call the EndEdit method for each BindingSource. Alternatively, you can add the EndEditOnAllBindingSources method to the form and call it before you perform a save.
To call EndEdit for all BindingSource components on a form
Add the following code to the form that contains the BindingSource components.
Add the following line of code immediately before any calls to save the form's data (the TableAdapterManager.UpdateAll() method):