Question TextBox Validation...

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
One of the things about applications that annoys me is when trying to cancel a form that has an invalid entry in some text field that must go through validation. Even though I'm trying to cancel the form, and the invalid entry will be dumped anyway, the validation process will not allow any input other than correcting this entry. So before I can dump the whole form, I must go back and correct this entry first. Is there any way to tell, within the validation code, that the user has clicked the Close or Cancel button, and that validation is no longer neccessary?
 
It's not within the validation code. You set the CausesValidation property of your Cancel button to False and then, when that button gets focus, the previous control won't raise its Validating or Validated events. It still raises its Leave event though, which is one reason that validation belongs in the Validating handler event. Note, this is from the documentation for the Validating and Validated events:
MSDN said:
If the CausesValidation property is set to false, the Validating and Validated events are suppressed.
If you look in the documentation first every time, you'll find your answers more often than not.
 
Back
Top