DateTimePickerFormat 列挙型

定義

DateTimePicker コントロールに表示する日時の書式を指定します。

public enum class DateTimePickerFormat
public enum DateTimePickerFormat
type DateTimePickerFormat = 
Public Enum DateTimePickerFormat
継承
DateTimePickerFormat

フィールド

Custom 8

DateTimePicker コントロールは、日付/時刻値をカスタム書式で表示します。 詳細については、「CustomFormat」を参照してください。

Long 1

DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている長い日付書式で日付/時刻値を表示します。

Short 2

DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている短い日付書式で日付/時刻値を表示します。

Time 4

DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている時刻の書式で日付/時刻値を表示します。

次のコード例では、 を 値に DateTimePicker 設定 Format してオブジェクトを初期化する方法を DateTimePickerFormat 示します。 この例を実行するには、次のコードをフォームに貼り付け、フォームのコンストラクターまたはLoadイベント処理メソッドから を呼び出InitializeDateTimePickerします。

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

注釈

この列挙は、 などの DateTimePicker.Formatメンバーによって使用されます。

注意

実際の日付/時刻形式は、ユーザーのオペレーティング システムで設定された日付、時刻、および地域の設定によって決まります。

適用対象

こちらもご覧ください