DateTimePicker.MaxDate DateTimePicker.MaxDate DateTimePicker.MaxDate DateTimePicker.MaxDate Property

定義

コントロールで選択できる日時の最大値を取得または設定します。Gets or sets the maximum date and time that can be selected in the control.

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

プロパティ値

コントロールで選択できる日時の最大値。The maximum date and time that can be selected in the control. 既定値は、CurrentCulture の calendar's MaxSupportedDateTimeプロパティの最小値と、午前12月31日の午前 9998 12 に決定されます。The default is determined as the minimum of the CurrentCulture's Calendar's MaxSupportedDateTime property and December 31st 9998 12 am.

例外

割り当てられた値が、MinDate 値より小さいです。The value assigned is less than the MinDate value.

割り当てられた値が、MaxDateTime 値を超えています。The value assigned is greater than the MaxDateTime 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. また、 CheckBox ShowUpDownプロパティは、コントロールがを表示するように設定され、コントロールがスピンボタンコントロール (アップダウンコントロールとも呼ばれます) として表示されるようにプロパティが設定されます。 ShowCheckBoxAlso, 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

適用対象

こちらもご覧ください