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.
The Enabled property determines whether a control/editor will be validated via user interaction; it is not applicable to programmatic validation. The solution you mention here, of assigning controls to be excluded, is the correct approach.
Another possible solution might be to implement the ICondition interface yourself (it is a very small interface), and pass validation for the controls that you don't want to be validated. You could then get around having to use ValidationGroups to bypass validation.
The following code sample demonstrates how to set the ValidationGroup property programmatically:
ValidationGroup disabledGroup = this.validator.ValidationGroups.Add( "Disabled" );ValidationSettings vs = this.validator.GetValidationSettings(myControl);vs.ValidationGroup = disabledGroup;
If this doesn't help you, please be more specific about why you can't change the validation group.
Thank you.