DateTimePicker.Format プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DateTimePicker Dim value As DateTimePickerFormat value = instance.Format instance.Format = value
public: property DateTimePickerFormat Format { DateTimePickerFormat get (); void set (DateTimePickerFormat value); }
/** @property */ public DateTimePickerFormat get_Format () /** @property */ public void set_Format (DateTimePickerFormat value)
public function get Format () : DateTimePickerFormat public function set Format (value : DateTimePickerFormat)
DateTimePickerFormat 値の 1 つ。既定値は Long です。


このプロパティは、日付を表示するときに適用する日時の書式を決定します。日時の書式は、オペレーティング システム上のカルチャに基づいて決定されます。
![]() |
---|
表示される日時の書式を CustomFormat プロパティで指定できるようにするには、Format プロパティを DateTimePickerFormat.Custom に設定する必要があります。 |
時刻だけを DateTimePicker に表示するには、Format を Time に設定し、ShowUpDown プロパティを false に設定します。

DateTimePicker で日付が "June 01, 2001 - Friday" と表示されるように、CustomFormat プロパティを設定するコード例を次に示します。このコードは、DateTimePicker コントロールのインスタンスが Form 上に作成されていることを前提にしています。
Public Sub SetMyCustomFormat() ' Set the Format type and the CustomFormat string. dateTimePicker1.Format = DateTimePickerFormat.Custom dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd" End Sub 'SetMyCustomFormat
public void SetMyCustomFormat() { // Set the Format type and the CustomFormat string. dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"; }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DateTimePickerFormat 列挙体
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Enumeration DateTimePickerFormat

メンバ名 | 説明 | |
---|---|---|
![]() | Custom | DateTimePicker コントロールは、日付/時刻値をカスタム書式で表示します。 |
![]() | Long | DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている長い日付書式で日付/時刻値を表示します。 |
![]() | Short | DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている短い日付書式で日付/時刻値を表示します。 |
![]() | Time | DateTimePicker コントロールは、ユーザーのオペレーティング システムで設定されている時刻の書式で日付/時刻値を表示します。 |

この列挙体は、DateTimePicker.Format などのメンバで使用されます。
![]() |
---|
実際に表示される日時の書式は、ユーザーのオペレーティング システムで設定されている日付、時刻、および地域設定によって決まります。 |

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDateTimePickerFormatを検索する場合は、下記のリンクをクリックしてください。

- DateTimePickerFormatのページへのリンク