How do I keep bindings from firing TextChanged event?
I'm using the Control.TextChanged event to detect when the user has modified the form. I have a method that loops through every control and adds the same TextChanged to all the controls.
My problem is, on the form I also have databinding that binds bindings that have Binding.Format() and Binding.Parse(), and these are within a TabControl. If the user changes tabs (Select开发者_JS百科edIndexChanged), it then activates the Format/Parse and fires the TextChanged event which makes it seem like the form's been modified!
How can I either (1) keep the bindings or Binding.Format and .Parse from firing the TextChanged event, or (2) implement a better way to detect of the controls on the form have been modified?
Instead of checking the actual TextChanged
Event, check the backing properties and look at when they change. You can make use of INotifyPropertyChanged
to help out with this.
精彩评论