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à

DateTime

Valore DateTime da assegnare al controllo.

Attributi

Eccezioni

Il valore impostato è minore di MinDate o maggiore di MaxDate.

Esempio

Nell'esempio di codice seguente viene illustrato come usare la Value proprietà per recuperare il valore della data corrente. In primo luogo, nell'esempio viene visualizzata la Value proprietà . L'esempio incrementa quindi la Value proprietà per un giorno e visualizza di nuovo 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, è impostata sulla data e l'ora correnti (DateTime.Now).

Si applica a

Vedi anche