When designing the interface, we often encounter the need to verify some input to ensure the validity of user input.ProgramAs far as possible, the validation should be performed at the beginning, that is, the user enters the verification, then we use validate and causesvalidation.
So how can we differentiate between validate and causesvalidation?
1. Validate is an event and causesvalidation is an attribute.
2. Example
Private sub object_validate (keepfocus as Boolean)
Keepfocus: determines whether the control loses the focus value. When keepfocus is set to true, the control remains focused.
validate event, this occurs before the focus is converted to another control. In this case, the
causesvalidation attribute value of the other control is set to
true (note: This is
prerequisite , if the value of the
causesvalidation attribute is set to
false, the
validate
event
will not occur) . when a control loses its focus, the first event to be triggered is its validation event (similarly, the causesvalidation attribute of the control to be focused needs to be set to true, otherwise the validation will not be triggered ). With this feature, you can
check the validity of data before the control loses focus.
The user control provides a validate event. It also provides a causesvalidation attribute through the extender object. When the focus is transferred from the user control to other controls whose causesvalidation attribute is set to trueCodeWill be executed. If you set the causesvalidation attribute of the user control to true, any validation event that passes focus to the control of the user control will be triggered. Otherwise, when causesvalidation
If the attribute is set to false, the validate event is not triggered!