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.
If you need to require users to enter data in a well-defined format, such as a telephone number or a part number, you can accomplish this quickly and with minimal code by using the Masked Text Box control.
This approach is useful when you want to give the user immediate feedback about the data as they are working.
If you want to use implicit validation for a control, you must set that control's Auto Validate property to .
If you cancel the Validating event, the behavior of the control will be determined by what value that you assigned to Auto Validate.
If you assigned Enable Prevent Focus Change, canceling the event will cause the Validated event not to occur.