Detecting user changes to a control

  • Thread starter Thread starter James Daughtry
  • Start date Start date
J

James Daughtry

Let's say that I have some data bound controls on a form. What I want
to do is check for a dirty state on those controls for when the user
actively changes a value and throw a message box prompting for
confirmation. However, if I use the TextChanged event on a text box,
for example, the message box will be thrown *any* time the text is
changed, including databinding and navigating records even if the
"state" isn't dirty according to my application.

Now, for a text box I can grab the KeyPress event and assume that a
change is made, but this isn't so simple for other controls like check
boxes or numeric up downs.

Is there a clean way of doing what I want without handling every event
under creation and manually doing the kind of stuff that I would expect
..NET to do for me? ;-)

Thanks!
 
Bob said:
Perhaps using the validating event would be better for your case.

I'll look into that. I must have been mistaken about when and how the
validating event is raised. What I ended up doing was providing an
interface in my user controls to enable and disable events. That way
the parent form can disable events when a non-user change is done and
re-enable them afterward.
 
Back
Top