The current date value is set to the MinDate or to the MaxDate in a DateTimePicker control in Windows Vista or in Windows Server 2008
Consider the following scenario:
- You have an application that uses a DateTimePicker control.
- This DateTimePicker control has two properties: MinDate and MaxDate. The month of the MinDate and the MaxDate are not set to the current month.
- You run the application in a Windows Vista or a Windows Server 2008 environment.
In this scenario, the current date value is set either to the MinDate or to the MaxDate.
For example, assume that the current date is January 26, 2010. You add two DateTimePicker controls to a Microsoft Windows Forms application.
For control 1, you set the MinDate and the MaxDate properties as follows:
- Me.DateTimePicker1.MinDate as 2009/12/01
- Me.DateTimePicker1.MaxDate as 2009/12/30
- Me.DateTimePicker1.Value as 2010/01/26
You select any dates on this DateTimePicker control. When you click this DateTimePicker control again, the current date is set to the value of the MaxDate.
For control 2, you set the MinDate and the MaxDate properties as follows:
- Me.DateTimePicker2.MinDate as 2009/02/01
- Me.DateTimePicker2.MaxDate as 2009/02/28
- Me.DateTimePicker2.Value as 2010/01/26
You select any dates on this DateTimePicker control. In this example, when you click the DateTimePicker control again, the current date is set to the value of the MinDate.
For more information on this issue, including potential causes, workarounds, and resolutions, see: Microsoft KB Article KB979535.