DateTimePicker クラスとは? わかりやすく解説

DateTimePicker クラス

ユーザー日時選択し書式指定して日時表示できる Windows コントロール表します

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

<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class DateTimePicker
    Inherits Control
Dim instance As DateTimePicker
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class DateTimePicker : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class DateTimePicker : public
 Control
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class DateTimePicker extends Control
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class DateTimePicker extends
 Control
解説解説

DateTimePicker コントロール使用すると、ユーザー日時選択し書式指定してその日時を表示できます。MinDate プロパティと MaxDate プロパティ設定すると、選択できる日時制限できます

CalendarForeColor、CalendarFont、CalendarTitleBackColor、CalendarTitleForeColor、CalendarTrailingForeColor、CalendarMonthBackground の各プロパティ設定すると、コントロール予定表部分外観変更できます

Format プロパティは、コントロールの DateTimePickerFormat を設定します日付既定Format は、DateTimePickerFormat.Long です。Format プロパティが DateTimePickerFormat.Custom に設定されている場合は、CustomFormat プロパティ設定しカスタム書式指定文字列作成することによって、独自の書式スタイル作成できますカスタム書式指定文字列は、カスタム フィールド文字その他のリテラル文字組み合わせて作成できます。たとえば、日付を "June 01, 2001 - Friday" と表示するには、CustomFormat プロパティを "MMMM dd, yyyy - dddd" に設定します詳細については、「日付と時刻書式指定文字列」を参照してください

スピン ボタン コントロール (アップダウン コントロール) を使用して日付/時刻値を指定できるようにする場合は、ShowUpDown プロパティtrue設定します予定表コントロール選択しても、ドロップダウン リスト表示されません。日時指定するには、各要素個別選択し上向き矢印ボタン下向き矢印ボタン使用して値を変更します

カスタム日付書式 (たとえば、選択できる日を 1 日だけに制限する) が必要な場合には、MonthCalendar ではなく DateTimePicker コントロール使用しますDateTimePicker使用すると、日付/時刻値として指定され検証対象とするデータ限定されます。

メモメモ

DateTimePicker コントロールグレゴリオ暦だけをサポートしてます。

使用例使用例

DateTimePicker コントロール新しインスタンス作成し初期化するコード例次に示しますコントロールCustomFormat プロパティ設定されます。また、コントロールCheckBox表示されるように ShowCheckBox プロパティ設定されコントロールスピン ボタン コントロール (アップダウン コントロール) として表示されるように ShowUpDown プロパティ設定されます。

Public Sub CreateMyDateTimePicker()
    ' Create a new DateTimePicker control and initialize it.
    Dim dateTimePicker1 As New
 DateTimePicker()
    
    ' Set the MinDate and MaxDate.
    dateTimePicker1.MinDate = New DateTime(1985, 6, 20)
    dateTimePicker1.MaxDate = DateTime.Today
    
    ' Set the CustomFormat string.
    dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"
    dateTimePicker1.Format = DateTimePickerFormat.Custom
    
    ' Show the CheckBox and display the control as an up-down control.
    dateTimePicker1.ShowCheckBox = True
    dateTimePicker1.ShowUpDown = True
End Sub 'CreateMyDateTimePicker
public void CreateMyDateTimePicker()
{
   // Create a new DateTimePicker control and initialize it.
   DateTimePicker dateTimePicker1 = new DateTimePicker();

   // Set the MinDate and MaxDate.
   dateTimePicker1.MinDate = new DateTime(1985, 6, 20);
   dateTimePicker1.MaxDate = DateTime.Today;

   // Set the CustomFormat string.
   dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";
   dateTimePicker1.Format = DateTimePickerFormat.Custom;

   // Show the CheckBox and display the control as an up-down control.
   dateTimePicker1.ShowCheckBox = true;
   dateTimePicker1.ShowUpDown = true;
}
   
public:
   void CreateMyDateTimePicker()
   {
      // Create a new DateTimePicker control and initialize it.
      DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
      
      // Set the MinDate and MaxDate.
      dateTimePicker1->MinDate = DateTime(1985,6,20);
      dateTimePicker1->MaxDate = DateTime::Today;
      
      // Set the CustomFormat string.
      dateTimePicker1->CustomFormat = "MMMM dd, yyyy - dddd";
      dateTimePicker1->Format = DateTimePickerFormat::Custom;
      
      // Show the CheckBox and display the control as an up-down control.
      dateTimePicker1->ShowCheckBox = true;
      dateTimePicker1->ShowUpDown = true;
   }
public void CreateMyDateTimePicker()
{
    // Create a new DateTimePicker control and initialize it.
    DateTimePicker dateTimePicker1 = new DateTimePicker();

    // Set the MinDate and MaxDate.
    dateTimePicker1.set_MinDate(new DateTime(1985, 6, 20));
    dateTimePicker1.set_MaxDate(DateTime.get_Today());

    // Set the CustomFormat string.
    dateTimePicker1.set_CustomFormat("MMMM dd, yyyy - dddd");
    dateTimePicker1.set_Format(DateTimePickerFormat.Custom);

    // Show the CheckBox and display the control as an up-down control.
    dateTimePicker1.set_ShowCheckBox(true);
    dateTimePicker1.set_ShowUpDown(true);
} //CreateMyDateTimePicker
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.DateTimePicker
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DateTimePicker クラス」の関連用語

DateTimePicker クラスのお隣キーワード
検索ランキング

   

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



DateTimePicker クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS