Regular expression for validating date of birth
Assigning Disable to the Auto Validate property prevents implicit validation altogether.
You can validate the data as the data is entered in a control by reading the keys as they are pressed, or more commonly whenever the user takes the input focus away from one control and moves to the next.
When the user action occurs, you can trigger explicit validation in one of the following ways: However, in some cases, you might want to let the user close the form regardless of whether the values in the controls are valid.
You can override validation and close a form that still contains invalid data by creating a handler for the form's Closing event.
For a code example that validates an email address in a Text Box, see Validating.
Validation is very useful when you have bound your controls to a data source, such as a database table.If you determine that the control's data is not valid, you can cancel the Validating event by setting this object's Cancel property to .If you do not set the Cancel property, Windows Forms will assume that validation succeeded for that control, and raise the Validated event.For example, if you have code in a Validated event that attempts to cancel the data binding, the data binding will still occur.