DateTimePicker.MaxDate Property

Definition

Obtiene o establece la fecha y hora máximas que se pueden seleccionar en el control.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

Property Value

DateTime

Fecha y hora máximas que se pueden seleccionar en el control.The maximum date and time that can be selected in the control. El valor predeterminado se determina como el mínimo de la propiedad Calendar's MaxSupportedDateTime de CurrentCulture y el 31 de diciembre de 9998 12 a.m.The default is determined as the minimum of the CurrentCulture's Calendar's MaxSupportedDateTime property and December 31st 9998 12 am.

Exceptions

El valor asignado es menor que el valor MinDate .The value assigned is less than the MinDate value.

El valor asignado es mayor que el valor MaxDateTime .The value assigned is greater than the MaxDateTime value.

Examples

En el ejemplo de código siguiente se crea una nueva instancia de un control DateTimePicker y se inicializa.The following code example creates a new instance of a DateTimePicker control and initializes it. Se establece la propiedad CustomFormat del control.The control's CustomFormat property is set. Además, la propiedad ShowCheckBox se establece para que el control muestre un CheckBoxy se establezca la propiedad ShowUpDown de modo que el control se muestre como un control de botón de número (también conocido como control de flechas).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

Applies to

See also