Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Disabling validation on specific controls
posted

I've been using the WinValidator control and, so far, it's much more useful than the built-in ErrorProvider.

However, I've come across an issue with not being able to turn off the validation on controls on-the-fly. I have multiple controls on one form that may or may not be displayed based on other selections. I have every control set to IsRequired and some have additional conditions. I figure out which ones need to be enabled, run Validate() and close the form if IsValid is true. What is happening is that all of the controls get validated, regardless of whether that Enabled flag is set.

ultraValidator1.GetValidationSettings(txtTitle).Enabled = false;
Infragistics.Win.Misc.Validation v = ultraValidator1.Validate();
if ( v.IsValid )
{
    //Currently requiring that txtTitle fits the validation requirements
}

This doesn't seem like the correct behavior... Is there another use for Enabled when it comes to the ValidationSettings? My work-around for the time-being is to set every control to one ValidationGroup ("EnabledValidationGroup") at design-time, and then at run-time, move the controls that I don't want validated into a second ValidationGroup ("DisabledValidationGroup"). Then, I run Validate() on the "EnabledValidationGroup".

This works for the time-being, but I'd rather use ValidationGroups for another use. I can see this getting cumbersome if I find a need for them.

Parents Reply Children
No Data