Validate during a Specific Event
Not only can WinValidator™ validate all Ultimate UI for Windows Forms controls and components, it can also validate any in-box, windows forms control or component. WinValidator validates a control at a specific time, or in other words, during a specific event. You can choose during which event WinValidator validates a control with the ValidationTrigger property. The ValidationTrigger property is aptly named for defining which type of event triggers a validation on a control or group of controls. There are several ways a control can trigger its own validation.
-
OnValidating – WinValidator validates the control when its Validating event fires.
-
OnPropertyValueChanged – WinValidator validates the control when a specific property’s Changed event fires. You can choose the property that triggers validation by setting the ValidationPropertyName property off the ValidationSettings object extended to each control by WinValidator. For more information, see Validate a Single Control.
-
Programmatic – WinValidator will not validate the control unless you specifically call the Validate method.
The following example code demonstrates how to validate the WinNumericEditor™ control during its TextChanged event. Validating during WinNumericEditor’s TextChanged event can be useful if you need to validate the editor as your end user types.
' Get the settings that determine how
' WinNumericEditor will be validated.
Dim vs As Infragistics.Win.Misc.ValidationSettings = _
Me.ultraValidator1.GetValidationSettings(Me.UltraNumericEditor1)
' Set the trigger to validate when a specific property is changed.
vs.ValidationTrigger = _
Infragistics.Win.Misc.ValidationTrigger.OnPropertyValueChanged
' The property whose "changed" event will be validated
' (i.e. the TextChanged event)
vs.ValidationPropertyName = "Text"
// Get the settings that determine how
// WinNumericEditor will be validated.
Infragistics.Win.Misc.ValidationSettings vs =
this.ultraValidator1.GetValidationSettings(this.ultraNumericEditor1);
// Set the trigger to validate when a specific property is changed.
vs.ValidationTrigger =
Infragistics.Win.Misc.ValidationTrigger.OnPropertyValueChanged;
// The property whose "changed" event will be validated
// (i.e. the TextChanged event)
vs.ValidationPropertyName = "Text";