How not to trigger Validating event?

Joined
Dec 10, 2007
Messages
18
Location
Florida
Programming Experience
Beginner
How can I not have the validating event trigger if my genericCheckBox is being unchecked. My genericTextBox does not allow letters. I have a validating event that will pop up a message box if there is a letter in the genericTextBox.

For instance, suppose genericCheckBox is checked and I put a letter in genericTextBox. Then, I uncheck genericCheckBox but my validating event does not let me uncheck genericCheckBox unless the value is valid.

How can I allow my program to be able to allow a user to uncheck genericCheckBox without validating the genericTextBox?

Unchecking genericCheckBox disables genericTextBox if the value is valid.
Any help will be greatly appreciated!
 
Set the CausesValidation property of the CheckBox to False. Note that the Validating event of the TextBox will still be raised when focus moves to another control whose CausesValidation property is True. At that point though, the Enabled property of the TextBox will be False so you simply don't bother validating the Text if it's disabled.
 
I should point out that, like so many people, you have wasted many hours searching. You shouldn't have been searching at all. You should have gone immediately to the MSDN documentation for the Validating event, where you would have read this:
MSDN said:
If the CausesValidation property is set to false, the Validating and Validated events are suppressed.
You would have had your answer in seconds if you'd simply looked in (what I consider to be) the obvious place. Use the documentation. Use the index.
 
Back
Top