By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Cancel a validation event based on what comes next

P: n/a
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
Mar 24 '06 #1
Share this Question
Share on Google+
1 Reply


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

"JohnR" <Jo******@hotmail.com> wrote in message
news:31KUf.1499$Qm2.75@trndny03...
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

Mar 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.