Condividi tramite


DateTimePicker.Value Proprietà

Definizione

Ottiene o imposta il valore di data/ora assegnato al controllo.

public:
 property DateTime Value { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Bindable(true)]
public DateTime Value { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Value : DateTime with get, set
Public Property Value As DateTime

Valore della proprietà

Valore DateTime assegnato al controllo.

Attributi

Eccezioni

Il valore impostato è minore MinDate o maggiore di MaxDate.

Esempio

Nell'esempio di codice seguente viene illustrato come utilizzare la Value proprietà per recuperare il valore di data corrente. In primo luogo, nell'esempio viene visualizzata la Value proprietà . Nell'esempio viene quindi incrementata di un giorno la Value proprietà e viene nuovamente visualizzato il valore della proprietà.

public:
   MyClass()
   {
      // Create a new DateTimePicker
      DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
      array<Control^>^ myClassControls = {dateTimePicker1};
      Controls->AddRange( myClassControls );
      MessageBox::Show( dateTimePicker1->Value.ToString() );

      dateTimePicker1->Value = DateTime::Now.AddDays( 1 );
      MessageBox::Show( dateTimePicker1->Value.ToString() );
   }
public MyClass()
{
   // Create a new DateTimePicker
   DateTimePicker dateTimePicker1 = new DateTimePicker();
   Controls.AddRange(new Control[] {dateTimePicker1});
   MessageBox.Show(dateTimePicker1.Value.ToString());

   dateTimePicker1.Value = DateTime.Now.AddDays(1);
   MessageBox.Show(dateTimePicker1.Value.ToString());
}
Public Sub New()
   ' Create a new DateTimePicker
   Dim dateTimePicker1 As New DateTimePicker()
   Controls.AddRange(New Control() {dateTimePicker1})
   MessageBox.Show(dateTimePicker1.Value.ToString())
   
   dateTimePicker1.Value = DateTime.Now.AddDays(1)
   MessageBox.Show(dateTimePicker1.Value.ToString())
End Sub

Commenti

Se la Value proprietà non è stata modificata nel codice o dall'utente, viene impostata sulla data e l'ora correnti (DateTime.Now).

Si applica a

Vedi anche