Freigeben über


DateTimePickerFormat-Enumeration

Gibt das im DateTimePicker-Steuerelement angezeigte Datums- und Zeitformat an.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Enumeration DateTimePickerFormat
'Usage
Dim instance As DateTimePickerFormat
public enum DateTimePickerFormat
public enum class DateTimePickerFormat
public enum DateTimePickerFormat
public enum DateTimePickerFormat

Member

  Membername Beschreibung
Unterstützt von .NET Compact Framework Custom Im DateTimePicker-Steuerelement wird der Wert von Datum und Uhrzeit in einem benutzerdefinierten Format angezeigt. 
Unterstützt von .NET Compact Framework Long Im DateTimePicker-Steuerelement wird der Wert von Datum und Uhrzeit im langen Datumsformat angezeigt, das durch das Betriebssystem des Benutzers festgelegt ist. 
Unterstützt von .NET Compact Framework Short Im DateTimePicker-Steuerelement wird der Wert von Datum und Uhrzeit im kurzen Datumsformat angezeigt, das durch das Betriebssystem des Benutzers festgelegt ist. 
Unterstützt von .NET Compact Framework Time Im DateTimePicker-Steuerelement wird der Wert von Datum und Uhrzeit in dem Zeitformat angezeigt, das durch das Betriebssystem des Benutzers festgelegt ist. 

Hinweise

Diese Enumeration wird von Membern wie DateTimePicker.Format verwendet.

Hinweis

Die tatsächlichen Datums- und Zeitformate werden durch Datum, Zeit und Ländereinstellungen im Betriebssystem des Benutzers bestimmt.

Beispiel

Im folgenden Codebeispiel wird das Initialisieren eines DateTimePicker-Steuerelements durch Festlegen der Format-Eigenschaft auf einen DateTimePickerFormat-Wert veranschaulicht. Zum Ausführen dieses Beispiels fügen Sie folgenden Code in ein Formular ein, und rufen Sie InitializeDateTimePicker im Konstruktor oder in der Load-Ereignisbehandlungsmethode des Formulars auf.

' 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
// 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);
}
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.
private System.Windows.Forms.DateTimePicker dateTimePicker1;

private void InitializeDateTimePicker()
{
    // Construct the DateTimePicker.
    this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
    //Set size and location.
    this.dateTimePicker1.set_Location(new System.Drawing.Point(40, 88));
    this.dateTimePicker1.set_Size(new System.Drawing.Size(160, 21));
    // Set the alignment of the drop-down MonthCalendar to right.
    this.dateTimePicker1.set_DropDownAlign(LeftRightAlignment.Right);
    // Set the Value property to 50 years before today.
    dateTimePicker1.set_Value(System.DateTime.get_Now().AddYears(-50));
    //Set a custom format containing the string "of the year"
    dateTimePicker1.set_Format(DateTimePickerFormat.Custom);
    dateTimePicker1.set_CustomFormat("MMM dd, 'of the year' yyyy ");
    // Add the DateTimePicker to the form.
    this.get_Controls().Add(this.dateTimePicker1);
} //InitializeDateTimePicker

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

System.Windows.Forms-Namespace
DateTimePicker-Klasse
DateTime