I have a BindingSource (employeeBindingSource) who's DataSource is an object array (Employee).
It is bound to a BindingNavigator, a ToolStripComboBox, and several Common Windows Form Controls.
GOAL: Fire only one event when the user changes a bound value. Such as text in a TextBox, state of a CheckBox, value of a DateTimePicker, etc.
PROBLEM: I am handling the CurrentItemChanged event but whenever the user changes a text value, this event gets fired twice on validation. According to MSDN, this is expected since it is fired once for the property change and again for the CurrentChanged.
I tried to handle the ListChanged event and checked the ListChangedType for ItemChanged. I got the same results. The event was fired twice!
So, which event(s) will allow me to detect changes in a BindingSource's Current properties just once per change?
employeeBindingSource.DataSource = _hrClient.GetEmployees(null, null, true, false);
employeeBindingSource.CurrentItemChanged += employeeBindingSource_CurrentItemChanged;
employeeBindingSource.ListChanged += employeeBindingSource_ListChanged;
bindingNavigator.BindingSource = employeeBindingSource;
// The following methods allowed me to see the events fired multiple times
private void employeeBindingSource_CurrentItemChanged(object sender, EventArgs e)
string text = lstPastStudiesEmp.Items.Count + " CurrentItemChanged";
private void employeeBindingSource_ListChanged(object sender, ListChangedEventArgs e)
string text = lstPastStudiesEmp.Items.Count + " " + e.ListChangedType;