In this simple example, the only candidate is the main form. To illustrate the principal, I've coded a call to the Validate method from the Click event of the form.--------Click Here to display the illustration--------(Keep in mind that this only happens when Auto Validate is Disable.)The other Validate overload passes a boolean. NET whether to check the current value of the Auto Validate property. Passing False gives the same result that you get with no parameter at all and results in the Validating and Validated events being triggered.
True checks Auto Validate so the events are not triggered. Validate(True) does not validateand Validate(False) does validate(When the Auto Validate property is Disable.)The Validate Children Method For explicit validation, Validate Children does more what I expected Validate to do.
Here's Validate Children responding to a button click.--------Click Here to display the illustration--------Validate Children is also more powerful because you can pass a parameter based on the Validation Constraints enumeration that limits which controls will actually trigger an evaluation.
You can choose from: None - validates all child controls Selectable - validates child controls that can be selected Enabled - validates child controls where Enabled is true Visible - validates child controls where Visible is true Tab Stop - validates child controls that have a Tab Stop value Immediate Children - validates child controls that are directly hosted in the container, but not the children of these children One last warning ...
If, somehow, you have managed to get to the end of this article and you still don't realize that all of these descriptions apply only when Auto Validate is set to Disable for the containing form, please be advised that they do.
The previous article in this two part series focuses more on validation when Auto Validate is set to something else.
By Dan Mabbutt The first Quick Tip Validation Guide defined validation as "the process of checking whether entered data is what it needs to be for the system to work correctly." And I noted in that article that: Windows form controls that have a Causes Validation property can fire a whole family of events when the focus shifts from the control.
Microsoft calls this "implicit validation" because the events are fired "implicitly" by . Microsoft refers to coding a call to the Validate or Validate Children method as "explicit validation".