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.You can still use control validation to lock focus to a control, but you do not have to be concerned about the behavior associated with closing the form.Microsoft is conducting an online survey to understand your opinion of the Msdn Web site.Assigning Disable to the Auto Validate property prevents implicit validation altogether.To validate your controls, you will have to use explicit validation.A is a string made up of characters from a masking language that specifies which characters can be entered at any given position in the text box. If the user types an incorrect entry, for example, the user types a letter when a digit is required, the control will automatically reject the input.The masking language that is used by Masked Text Box is very flexible.
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.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 .Windows Forms provides several ways for you to validate input in your application.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.
Search for maskedtextbox validating:
Input focus will remain on the current control until the user changes the data to a valid input.