DateTimePickerFormat Énumération

Définition

Spécifie le format de date et d’heure affiché par le contrôle DateTimePicker.

public enum class DateTimePickerFormat
public enum DateTimePickerFormat
type DateTimePickerFormat = 
Public Enum DateTimePickerFormat
Héritage
DateTimePickerFormat

Champs

Nom Valeur Description
Long 1

Le DateTimePicker contrôle affiche la valeur de date/heure dans le format de date long défini par le système d’exploitation de l’utilisateur.

Short 2

Le DateTimePicker contrôle affiche la valeur de date/heure dans le format de date court défini par le système d’exploitation de l’utilisateur.

Time 4

Le DateTimePicker contrôle affiche la valeur de date/heure dans le format d’heure défini par le système d’exploitation de l’utilisateur.

Custom 8

Le DateTimePicker contrôle affiche la valeur de date/heure dans un format personnalisé. Pour plus d’informations, consultez CustomFormat.

Exemples

L’exemple de code suivant illustre l’initialisation d’un DateTimePicker objet en définissant la Format valeur sur une DateTimePickerFormat valeur. Pour exécuter cet exemple, collez le code suivant dans un formulaire et appel InitializeDateTimePicker à partir de la méthode de construction ou Load de gestion des événements du formulaire.

internal:
   // Declare the DateTimePicker.
   System::Windows::Forms::DateTimePicker^ DateTimePicker1;

private:
   void InitializeDateTimePicker()
   {
      // Construct the DateTimePicker.
      this->DateTimePicker1 = gcnew System::Windows::Forms::DateTimePicker;
      
      //Set size and location.
      this->DateTimePicker1->Location = System::Drawing::Point( 40, 88 );
      this->DateTimePicker1->Size = System::Drawing::Size( 160, 21 );
      
      // Set the alignment of the drop-down MonthCalendar to right.
      this->DateTimePicker1->DropDownAlign = LeftRightAlignment::Right;
      
      // Set the Value property to 50 years before today.
      DateTimePicker1->Value = System::DateTime::Now.AddYears(  -50 );
      
      //Set a custom format containing the string "of the year"
      DateTimePicker1->Format = DateTimePickerFormat::Custom;
      DateTimePicker1->CustomFormat = "MMM dd, 'of the year' yyyy ";
      
      // Add the DateTimePicker to the form.
      this->Controls->Add( this->DateTimePicker1 );
   }

// Declare the DateTimePicker.
internal System.Windows.Forms.DateTimePicker DateTimePicker1;

private void InitializeDateTimePicker()
{
    // Construct the DateTimePicker.
    this.DateTimePicker1 = new System.Windows.Forms.DateTimePicker();

    //Set size and location.
    this.DateTimePicker1.Location = new System.Drawing.Point(40, 88);
    this.DateTimePicker1.Size = new System.Drawing.Size(160, 21);
    
    // Set the alignment of the drop-down MonthCalendar to right.
    this.DateTimePicker1.DropDownAlign = LeftRightAlignment.Right;

    // Set the Value property to 50 years before today.
    DateTimePicker1.Value = System.DateTime.Now.AddYears(-50);

    //Set a custom format containing the string "of the year"
    DateTimePicker1.Format = DateTimePickerFormat.Custom;
    DateTimePicker1.CustomFormat = "MMM dd, 'of the year' yyyy ";

    // Add the DateTimePicker to the form.
    this.Controls.Add(this.DateTimePicker1);
}

' Declare the DateTimePicker.
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker


Private Sub InitializeDateTimePicker()

    ' Construct the DateTimePicker.
    Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker

    'Set size and location.
    Me.DateTimePicker1.Location = New System.Drawing.Point(40, 88)
    Me.DateTimePicker1.Size = New Size(160, 21)
    
    ' Set the alignment of the drop-down MonthCalendar to right.
    Me.DateTimePicker1.DropDownAlign = LeftRightAlignment.Right

    ' Set the Value property to 50 years before today.
    DateTimePicker1.Value = (DateTime.Now.AddYears(-50))

    'Set a custom format containing the string "of the year"
    DateTimePicker1.Format = DateTimePickerFormat.Custom
    DateTimePicker1.CustomFormat = "MMM dd, 'of the year' yyyy "

    ' Add the DateTimePicker to the form.
    Me.Controls.Add(Me.DateTimePicker1)
End Sub

Remarques

Cette énumération est utilisée par les membres tels que DateTimePicker.Format.

Note

Les formats de date/heure réels sont déterminés par la date, l’heure et les paramètres régionaux définis dans le système d’exploitation de l’utilisateur.

S’applique à

Voir aussi