DateTimePicker.MinDate DateTimePicker.MinDate DateTimePicker.MinDate DateTimePicker.MinDate Property

定義

取得或設定控制項中可選取的最小日期和時間。Gets or sets the minimum date and time that can be selected in the control.

public:
 property DateTime MinDate { DateTime get(); void set(DateTime value); };
public DateTime MinDate { get; set; }
member this.MinDate : DateTime with get, set
Public Property MinDate As DateTime

屬性值

控制項中可選取的最小日期和時間。The minimum date and time that can be selected in the control. 預設是 1/1/1753 00:00:00。The default is 1/1/1753 00:00:00.

例外狀況

指派的值不小於 MaxDate 值。The value assigned is not less than the MaxDate value.

指派的值小於 MinDateTime 值。The value assigned is less than the MinDateTime value.

範例

下列程式碼範例會建立DateTimePicker控制項的新實例, 並將它初始化。The following code example creates a new instance of a DateTimePicker control and initializes it. 已設定控制項CustomFormat的屬性。The control's CustomFormat property is set. 此外, ShowCheckBox也會設定屬性, 讓控制項CheckBox顯示, 並ShowUpDown設定屬性, 讓控制項顯示為微調按鈕控制項 (也稱為上下按鈕控制項)。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 a spin button control (also known as an up-down control).

public:
   void CreateMyDateTimePicker()
   {
      // Create a new DateTimePicker control and initialize it.
      DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
      
      // Set the MinDate and MaxDate.
      dateTimePicker1->MinDate = 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;
   }
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;
}
   
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

適用於

另請參閱