DateTimePicker.Value Propriété

Définition

Obtient ou définit la valeur de date/heure assignée au contrôle.

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

Valeur de propriété

DateTime

Valeur DateTime assignée au contrôle.

Attributs

Exceptions

La valeur définie est inférieure à MinDate ou supérieure à MaxDate.

Exemples

L’exemple de code suivant montre comment utiliser la Value propriété pour récupérer la valeur de date actuelle. Tout d’abord, l’exemple affiche la Value propriété. L’exemple incrémente ensuite la Value propriété d’un jour et affiche à nouveau la valeur de la propriété.

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

Remarques

Si la Value propriété n’a pas été modifiée dans le code ou par l’utilisateur, elle est définie sur la date et l’heure actuelles (DateTime.Now).

S’applique à

Voir aussi