Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

textbox Leave event

I have validation in the leave event of a textbox.  one thing that I notice happening is when I click a button to cancel out of the form and the validation isn't correct it won't let me dispose of the form.  The validation stops it.  Really the validation is doing exactly what I want it to but I need to be able to hit the button and basically have that override the validation.  Is there a way to do that in the Leave event?
0
oak29
Asked:
oak29
2 Solutions
 
rawinnlnx9Commented:
Try changing this in your leave event:

textBox.CausesValidation = False;

Alternatively you could also set some flag bool EnableValidation=true; and then set it to false then have your validation events check that value before proceeding.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Actually, you need to set CausesValidation=false on your "cancel" button, rather than on the textbox itself.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now