tommyf Posted July 26, 2004 Posted July 26, 2004 I have the validating event on some of my text boxes on my windows form. When I press a search button my controls clear and some of them are enabled and some are not. The problem I have is that I can do a search on one or all of the textboxes but if I click in a textbox and then change my mind on what I want to search for the validating event kicks in and I can't get out of it until I entry something into it. Can I turn the validating event on and off when needed at run time Quote
JABE Posted July 27, 2004 Posted July 27, 2004 I think the "change of mind" aspect is virtually impossible to distinguish from an omitted entry. You probably shouldn't be using a validation control for this. Anyway, you can dynamically concatenate your search criteria and just omit those w/c have blank values. But addressing the question, the workaround I'm using so far is to set CausesValidation = False for the control that shouldn't fire validation events (such as a Cancel button). The problem is if you close the form in the same event and the last control to have focus is a validating control, then the Validating event of that control will fire. So another workaround I did was to iterate thru Form.Controls and set CausesValidation of each control to False. Another option is setting a form-level flag in the Closing event of the form; in the Validating events, just eval this flag so that validations don't fire when the form is about to close. Quote
dhj Posted July 27, 2004 Posted July 27, 2004 you will have to change CauseValidation to false in your search button Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.