DateTimePicker.DropDownAlign Eigenschaft

Definition

Ruft die Ausrichtung des Dropdownkalenders im DateTimePicker-Steuerelement ab oder legt diese fest.

public:
 property System::Windows::Forms::LeftRightAlignment DropDownAlign { System::Windows::Forms::LeftRightAlignment get(); void set(System::Windows::Forms::LeftRightAlignment value); };
public System.Windows.Forms.LeftRightAlignment DropDownAlign { get; set; }
member this.DropDownAlign : System.Windows.Forms.LeftRightAlignment with get, set
Public Property DropDownAlign As LeftRightAlignment

Eigenschaftswert

Die Ausrichtung des Dropdownkalenders im Steuerelement. Der Standardwert ist Left.

Ausnahmen

Der zugewiesene Wert ist keiner der LeftRightAlignment-Werte.

Beispiele

Im folgenden Codebeispiel wird die Initialisierung eines DateTimePicker veranschaulicht, indem die DropDownAlignEigenschaften , Value, Formatund CustomFormat festgelegt werden. Fügen Sie zum Ausführen dieses Beispiels den folgenden Code in ein Formular ein, und rufen InitializeDateTimePicker Sie aus dem Konstruktor oder Load der Ereignisbehandlungsmethode des Formulars auf.

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

Hinweise

Der Dropdownkalender kann links oder rechts vom Steuerelement ausgerichtet werden.

Gilt für:

Weitere Informationen