DateTimePicker.MinDate Proprietà

Definizione

Ottiene o imposta la data e l’ora minime selezionabili nel controllo.

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

Valore della proprietà

La data e l’ora minime selezionabili nel controllo. Il valore predefinito è 1/1/1753 00:00:00.

Eccezioni

Il valore assegnato è superiore al valore di MaxDate.

-oppure-

Il valore assegnato è inferiore al valore di MinDateTime.

Esempio

L'esempio di codice seguente crea una nuova istanza di un DateTimePicker controllo e la inizializza. La proprietà del CustomFormat controllo è impostata. Inoltre, la ShowCheckBox proprietà viene impostata in modo che il controllo visualizzi un CheckBoxoggetto e che la ShowUpDown proprietà sia impostata in modo che il controllo venga visualizzato come controllo pulsante di selezione (noto anche come controllo di scorrimento).

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

Si applica a

Vedi anche