DCSIMG
Validation of a NumericUpDown control - Dotmad (on .Net)

Dotmad (on .Net)

Just Another Web 5.0 Blog

Podcasts

Blogroll

Validation of a NumericUpDown control

The NumericUpDown control has a built-in validation:
  • Values smaller than the minimum are replaced by the minimum
  • Values larger than the maximum are replaced by the maximum

This may lead to a situation in which the user entered an invalid value and pressed the form's "OK" button, leading to saving of a value completely different than the one entered with no notification.
To prevent this, enter your own validation code into the validating event (using the "Text" property instead of "Value"), and if the validation fails set the e.Cancel argument to "true".

 

פורסם: Nov 18 2007, 03:59 PM by Dotmad | with no comments
תגים: