Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How can I use the MaskedTextBox to tell if a date is between a certain range?

Use the MaskedTextBox's TypeValidationCompleted event. This event occurs when the MaskedTextBox loses focus and the static Parse method on the Type set into the ValidatingType proeprty is called.
The IsValidInput property on the TypeValidationEventArgs returns true if the Parse method succeeded. The ReturnValue property on the TypeValidationEventArgs returns the instance created by the Parse method.
You can then use the DateTime.Compare method to verify the DateTime is within a range.

See the shippedDateMaskedTextBox_TypeValidationCompleted in the Form1 class of the MaskedTextBoxDataBinding project for an example.