Detecting dirty use of winforms data binding

I use two-way binding for winforms text fields. I need to work if a user changes my data Looking for help for

CurrentItemChanged event

It appears that this event fires if the property has changed, however it also fires if the current has changed.

Is there a way to find out if the data has changed?

a similar question was also asked here but didn’t answer in my opinion

Oliver mentions "if your object in the list supports the INotifyPropertyChanged event, and you replace List with a BindingList, you can subscribe to the ListChanged event in the BindingList to get information about any changes made by the user."

My application meets these conditions, but I cannot get it to work. The ListChangedType.ItemChanged property looked encouraging, but it changes when I go to the next record without changing the data.

I found a link at Microsoft here , but of course it can't be that hard!

0
c # data-binding winforms 2-way-object-databinding
source share
1 answer

It seems to work

void bindingSource_BindingComplete(object sender, BindingCompleteEventArgs e) { if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate) { var person = (Person)bindingSource.Current; if ( person.State == State.Unchanged && (e.BindingCompleteState == BindingCompleteState.Success) && e.Binding.Control.Focused) { person.State = State.Modified; // using Julie Lerman repositories technique } } } 
0
source share

All Articles