The control also works well when bound to a data source.
The Format event on a data binding can be used to reformat incoming data to comply with the mask, and the Parse event can be used to reformat outgoing data to comply with the specifications of the data field. If you want full programmatic control over validation, or need to perform complex validation checks, you should use the validation events built into most Windows Forms controls.
The masking language that is used by Masked Text Box is very flexible.
Validation is very useful when you have bound your controls to a data source, such as a database table.
By using validation, you can make sure that your control's data satisfies the format required by the data source, and that it does not contain any special characters such as quotation marks and back slashes that might be unsafe.
In this case, to perform validation in the Validated event, change the control's Data Source Update Mode property (under (Databindings)\(Advanced)) from On Validation to Never, and add So when does a control's data get validated? You can use either implicit or explicit validation, depending on the needs of your application.
The implicit validation approach validates data as the user enters it.
You may require that certain text fields not be zero-length, that a field be formatted as a telephone number or other type of well-formed data, or that a string not contain any unsafe characters that could be used to compromise the security of a database.