Cancel a validation event based on what comes next

  • Thread starter Thread starter JohnR
  • Start date Start date
J

JohnR

I normally validate the data in a control in that controls validating event.
I also normally have a Cancel button on each form which does a RejectChanges
to reset any unsaved data on the form. Clearly, if the user puts invalid
data into a control and then hits the Cancel button there is no need to do
the validation since the data will all be reset anyway. My question is how
do I determine what was clicked that caused the original control to lose
focus and thereby kick off it's validating event.
Within the validating event I would want to determine if the user just
clicked the Cancel button and, if so, just exit the validating routine.
Is there a way this can be done? As of now, the user is forced to go back
to the control and put in 'good' data before he is allowed to 'cancel' and
that makes no sense at all.

John
 
About 15 min after I posted I found the answer. Simply set the
"CausesValidation" property of the Cancel button to false.
 
Back
Top