Microsoft KB Archive/822498

= ValueChanged event of the DateTimePicker control is not raised when you change the date =

Article ID: 822498

Article Last Modified on 5/16/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

-





SYMPTOMS
You set the date format and language in the regional settings on your computer and then add a DateTimePicker control to a Windows form. When you run the application and type a single digit in the date field of the DateTimePicker control, the ValueChanged event is not raised. The ValueChanged event of the control is raised only after you type any one of the following:
 * All the digits of a year.
 * All the digits of a day.
 * All the digits of a month.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
To set regional settings on your computer:  In Control Panel, double-click Regional and Language Options. On the Regional Options tab, select English (United States) from the list, and then click Customize. In the Customize Regional Options dialog box, click the Date tab. In the Short date format list under Short date, select yyyy-MM-dd, and then click OK. In the Regional and Language Options dialog box, click OK. Start Microsoft Visual Studio .NET.</li> Create a new Windows Application project by using Visual Basic .NET or Visual C# .NET. By default, Form1 is created.</li> Add a DateTimePicker control to Form1.</li> On Form1, right-click DateTimePicker1, and then click Properties.</li> In the Properties dialog box, set the Format property to Short.</li>  Add the following code to the DateTimePicker1_ValueChanged event handler:

Visual Basic .NET Code 'The event is raised when the value is changed. System.Windows.Forms.MessageBox.Show(&quot;Value Changed&quot;) Visual C# .NET Code //The event is raised when the value is changed. System.Windows.Forms.MessageBox.Show(&quot;Value Changed&quot;); </li> On the Build menu, click Build Solution.</li> On the Debug menu, click Start.</li> Type any date in the DateTimePicker1 control. The event is raised only after you enter 4 digits for a year, 2 digits for a month, or 2 digits for a day.</li></ol>

<div class="references_section">