Closing form causes validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a text box which uses the validating event to check if it's empty. If
the focus is set to this text box & I close the form, the event fires. I
don't want this to happen when I close the form. I tried setting the
'causesValidation' property of the form to false, but that didn't stop the
event firing. The false setting works ok for all other controls on the form
though.

How can I set this so as not to cause validation when I close the form?

Thanks ahead for answers
Ant
 
Ant,

Usually control valiadation is used in modal dialog boxes where the user is
supposed to enter some data that needs to be validated before submission. If
this is your case you have a cancel button. Set the cancel button
CausesValidation to false, set the form CancelButton property to this
button. this way you won't get validation when the user clicks on the X
button or on the Cancel button. The only problem is withe Esc key. I don't
have solution for that at the moment (haven't played with it). Try somehow
to handle this button and set a flag or something.
 
Hi Stoitcho,

Thanks, a modal dialog box is exactly what it is. I'll try your idea. Sounds
like it's what will work. It seems strange that there wouldn't be a standard
solution to this (regarding the Esc key) as it's a pretty standard use.

Thanks again for your help
Ant
 
Ant,

I agree with you and the only think I can say is that control validation has
never worked as we expect. It use to be very buggy as well.
 
Back
Top