3

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 (SelectedIndexChanged), 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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Isaac
  • 43
  • 1
  • 7

1 Answers1

0

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.

msarchet
  • 15,104
  • 2
  • 43
  • 66
  • Hmm... Could you possibly provide an example of this for me, please? I MSDN'ed the iNPC, but I'm not quite sure how to implement it for what I'm trying to do. It isn't as clear to me how I can use that property. – Isaac Mar 17 '11 at 16:58
  • Does it involve in any way the example at http://msdn.microsoft.com/en-us/library/ms184414.aspx of "How to: Raise Change Notifications Using a BindingSource and the INotifyPropertyChanged Interface?" – Isaac Mar 17 '11 at 20:43