次の方法で共有


DateTimePicker.DropDownAlign プロパティ

日時指定コントロール上のドロップダウン形式の予定表の配置を取得または設定します。

Public Property DropDownAlign As LeftRightAlignment
[C#]
public LeftRightAlignment DropDownAlign {get; set;}
[C++]
public: __property LeftRightAlignment get_DropDownAlign();public: __property void set_DropDownAlign(LeftRightAlignment);
[JScript]
public function get DropDownAlign() : LeftRightAlignment;public function set DropDownAlign(LeftRightAlignment);

プロパティ値

コントロール上のドロップダウン形式の予定表の配置。既定値は Left です。

例外

例外の種類 条件
InvalidEnumArgumentException 代入された値が、 LeftRightAlignment 値ではありません。

解説

ドロップダウン形式の予定表は、コントロールの左側または右側に揃えて配置できます。

使用例

[Visual Basic, C#] DropDownAlign プロパティ、 Value プロパティ、 Format プロパティ、および CustomFormat プロパティを設定して 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

[C#] 

    // 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);
    }

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DateTimePicker クラス | DateTimePicker メンバ | System.Windows.Forms 名前空間 | LeftRightAlignment