Cancel a validation event based on what comes next

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
 
J

JohnR

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top