Export (0) Print
Expand All

DateTimePicker.MinDate Property

Gets or sets the minimum date and time that can be selected in the control.

[Visual Basic]
Public Property MinDate As DateTime
[C#]
public DateTime MinDate {get; set;}
[C++]
public: __property DateTime get_MinDate();
public: __property void set_MinDate(DateTime);
[JScript]
public function get MinDate() : DateTime;
public function set MinDate(DateTime);

Property Value

The minimum date and time that can be selected in the control. The default is 1/1/1753 00:00:00.

Exceptions

Exception Type Condition
ArgumentException The value assigned is not less than the MaxDate value.
SystemException The value assigned is less than the MinDateTime value.

Example

[Visual Basic, C#, C++] The following example creates an new instance of a DateTimePicker control and initializes it. The control's CustomFormat property is set. Also, the ShowCheckBox property is set so that the control displays a CheckBox, and the ShowUpDown property is set so that the control is displayed as an up-down control.

[Visual Basic] 
Public Sub CreateMyDateTimePicker()
    ' Create a new DateTimePicker control and initialize it.
    Dim dateTimePicker1 As New DateTimePicker()
    
    ' Set the MinDate and MaxDate.
    dateTimePicker1.MinDate = New DateTime(1985, 6, 20)
    dateTimePicker1.MaxDate = DateTime.Today
    
    ' Set the CustomFormat string.
    dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"
    dateTimePicker1.Format = DateTimePickerFormat.Custom
    
    ' Show the CheckBox and display the control as an up-down control.
    dateTimePicker1.ShowCheckBox = True
    dateTimePicker1.ShowUpDown = True
End Sub 'CreateMyDateTimePicker

[C#] 
public void CreateMyDateTimePicker()
{
   // Create a new DateTimePicker control and initialize it.
   DateTimePicker dateTimePicker1 = new DateTimePicker();

   // Set the MinDate and MaxDate.
   dateTimePicker1.MinDate = new DateTime(1985, 6, 20);
   dateTimePicker1.MaxDate = DateTime.Today;

   // Set the CustomFormat string.
   dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";
   dateTimePicker1.Format = DateTimePickerFormat.Custom;

   // Show the CheckBox and display the control as an up-down control.
   dateTimePicker1.ShowCheckBox = true;
   dateTimePicker1.ShowUpDown = true;
}
   

[C++] 
public:
void CreateMyDateTimePicker()
{
   // Create a new DateTimePicker control and initialize it.
   DateTimePicker* dateTimePicker1 = new DateTimePicker();

   // Set the MinDate and MaxDate.
   dateTimePicker1->MinDate = DateTime(1985, 6, 20);
   dateTimePicker1->MaxDate = DateTime::Today;

   // Set the CustomFormat string.
   dateTimePicker1->CustomFormat = S"MMMM dd, yyyy - dddd";
   dateTimePicker1->Format = DateTimePickerFormat::Custom;

   // Show the CheckBox and display the control as an up-down control.
   dateTimePicker1->ShowCheckBox = true;
   dateTimePicker1->ShowUpDown = true;
}
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DateTimePicker Class | DateTimePicker Members | System.Windows.Forms Namespace | MinDateTime | MaxDate

Show:
© 2015 Microsoft