DateTimePicker.CustomFormat プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DateTimePicker.CustomFormat プロパティの意味・解説 

DateTimePicker.CustomFormat プロパティ

日付/時刻のカスタム書式指定文字列を取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<LocalizableAttribute(True)> _
Public Property CustomFormat As
 String
Dim instance As DateTimePicker
Dim value As String

value = instance.CustomFormat

instance.CustomFormat = value
[LocalizableAttribute(true)] 
public string CustomFormat { get;
 set; }
[LocalizableAttribute(true)] 
public:
property String^ CustomFormat {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_CustomFormat ()

/** @property */
public void set_CustomFormat (String value)
public function get CustomFormat
 () : String

public function set CustomFormat
 (value : String)

プロパティ値
カスタムの日付/時刻書式を表す文字列。既定値は null 参照 (Visual Basic では Nothing) です。

解説解説

日付と時刻の区切り記号や書式指定文字列を含むリテラル文字列を表示するには、部分文字列に対してエスケープ文字を使用する必要があります。たとえば、日付を "June 15 at 12:00 PM" と表示するには、CustomFormat プロパティを "MMMM dd 'at' t:mm tt" に設定します。部分文字列 "at" をエスケープ文字で囲まなかった場合は、"June 15 aP 12:00PM" と表示されます。これは、文字 "t" が 1 文字の A.M./P.M. の書式指定文字列として解釈されたためです (次の書式指定文字列の表を参照)。

書式指定文字列を組み合わせて、日付と時刻の書式を指定できます。たとえば、日付と時刻を 06/15/2001 12:00 PM と表示するには、このプロパティを "MM'/'dd'/'yyyy hh':'mm tt" に設定する必要があります。詳細については、「日付と時刻の書式指定文字列」を参照してください。

メモメモ

表示される日時の書式をこのプロパティで指定できるようにするには、Format プロパティを DateTimePickerFormat.Custom に設定する必要があります。

有効なすべての書式指定文字列とその説明を次の表に示します。

書式指定文字列

説明

d

1 桁または 2 桁の日付。

dd

2 桁の日付。日付値が 1 桁の場合、前に 0 が付きます。

ddd

3 文字の曜日の省略形。

dddd

完全な曜日名。

h

12 時間形式で表される 1 桁または 2 桁の時間。

hh

12 時間形式で表される 2 桁の時間。値が 1 桁の場合、前に 0 が付きます。

H

24 時間形式で表される 1 桁または 2 桁の時間。

HH

24 時間形式で表される 2 桁の時間。値が 1 桁の場合、前に 0 が付きます。

m

1 桁または 2 桁の分。

mm

2 桁の分。値が 1 桁の場合、前に 0 が付きます。

M

数字で表示する 1 桁または 2 桁の月。

MM

数字で表示する 2 桁の月。値が 1 桁の場合、前に 0 が付きます。

MMM

3 文字の月の省略形。

MMMM

完全な月の名前。

s

1 桁または 2 桁の秒。

ss

2 桁の秒。値が 1 桁の場合、前に 0 が付きます。

t

1 文字の A.M./P.M. の省略形 ("A.M." の場合は "A")。

tt

2 文字の A.M./P.M. の省略形 ("A.M." の場合は "AM")。

y

1 桁の年 (2001 年の場合は "1")。

yy

年の最後の 2 桁 (2001 の場合は "01")。

yyyy

完全な年 (2001 の場合は "2001")。

使用例使用例

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";
}

public:
   void SetMyCustomFormat()
   {
      // Set the Format type and the CustomFormat string.
      dateTimePicker1->Format = DateTimePickerFormat::Custom;
      dateTimePicker1->CustomFormat = "MMMM dd, yyyy - dddd";
   }
public void SetMyCustomFormat()
{
    // Set the Format type and the CustomFormat string.
    dateTimePicker1.set_Format(DateTimePickerFormat.Custom);
    dateTimePicker1.set_CustomFormat("MMMM dd, yyyy - dddd");
} //SetMyCustomFormat
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DateTimePicker クラス
DateTimePicker メンバ
System.Windows.Forms 名前空間
DateTimePickerFormat
Format



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

DateTimePicker.CustomFormat プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DateTimePicker.CustomFormat プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS