Microsoft KB Archive/814347

= BUG: The value in the NumericUpDown control does not reset to the maximum or minimum value if you use the TAB key or mouse to shift focus =

Article ID: 814347

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-





Beta Information
This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location from which you downloaded the release.



SYMPTOMS
The value in the NumericUpDown control does not reset to the maximum value if you type a value that is greater than the maximum value of a NumericUpDown control, and then press the TAB key or use a mouse to shift focus. Similarly, when you type a value that is less than the minimum value of the NumericUpDown control, the value does not reset to minimum value. If you press the ENTER key in the NumericUpDown control, the maximum value or minimum value is set.



CAUSE
When you type text in the NumericUpDown control, the Text property of the control is set to the new value. When you press the TAB key or use a mouse to shift your focus, the Value property of the control does not change. The Value property of the control continues to hold the previous value. Therefore, the value in the control does not change. When you use the Value property in code or you press the ENTER key in the control, the Value property is set to the text that you type. The new value is validated between the minimum and maximum values.



RESOLUTION
To work around this bug, add sample code to access the Value property in the validating or validated event for NumericUpDown. For example, add the following code in the NumericUpDown1 validating or validated event:

Visual Basic .NET Console.WriteLine(NumericUpDown1.Value) Visual C# .NET Console.WriteLine(numericUpDown1.Value);



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior

 * 1) Open Visual Basic .NET.
 * 2) On the File menu, point to New, and then click Project.
 * 3) Under Project Types, click to select Visual Basic projects or Visual C# projects.
 * 4) Under Templates, click to select Windows Application.

By default, Form1 is created.
 * 1) From the toolbox, drag the NumericUpDown control to Form1.

NumericUpDown1 is created.
 * 1) Right-click NumericUpDown1, and then click Properties.
 * 2) In the Properties window, locate the Minimum property and the Maximum property.

By default, the values for these properties are set to 0 and 100, respectively.
 * 1) From the toolbox, drag a TextBox control to Form1.
 * 2) On the Debug menu, click Start.

By default, the focus is on NumericUpDown1.
 * 1) Type a value greater than 100.
 * 2) Press the TAB key or click Textbox1 to shift focus.

The value in NumericUpDown1 does not change to 100.

