2016-04-11 10 views
0

私のプロジェクトでの作業中、私は奇妙な問題に遭遇しました。私のアプリケーションのToolStripでToolStripDropDownButtonの右揃えを実行すると、ウィンドウの外に表示されます。フルスクリーンでさえ、それは私の2番目のモニターに表示されます。私はメニューを適切に整列させるための窓の心配だと思ったが、間違っているようだ。私はWindowsフォームを使用します。ToolStripDropDownButtonがアプリケーションのウィンドウの外側に表示されるように右揃え

ここに私が話していることがあります。 同様の問題が発生しました。

partial class Form2 
{ 
    /// <summary> 
    /// Required designer variable. 
    /// </summary> 
    private System.ComponentModel.IContainer components = null; 

    /// <summary> 
    /// Clean up any resources being used. 
    /// </summary> 
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
    protected override void Dispose(bool disposing) 
    { 
     if (disposing && (components != null)) 
     { 
      components.Dispose(); 
     } 
     base.Dispose(disposing); 
    } 

    #region Windows Form Designer generated code 

    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor. 
    /// </summary> 
    private void InitializeComponent() 
    { 
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2)); 
     this.toolStrip1 = new System.Windows.Forms.ToolStrip(); 
     this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton(); 
     this.itemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
     this.toolStrip1.SuspendLayout(); 
     this.SuspendLayout(); 
     // 
     // toolStrip1 
     // 
     this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 
     this.toolStripDropDownButton1}); 
     this.toolStrip1.Location = new System.Drawing.Point(0, 0); 
     this.toolStrip1.Name = "toolStrip1"; 
     this.toolStrip1.Size = new System.Drawing.Size(763, 25); 
     this.toolStrip1.TabIndex = 0; 
     this.toolStrip1.Text = "toolStrip1"; 
     // 
     // toolStripDropDownButton1 
     // 
     this.toolStripDropDownButton1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; 
     this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; 
     this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 
     this.itemToolStripMenuItem}); 
     this.toolStripDropDownButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripDropDownButton1.Image"))); 
     this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta; 
     this.toolStripDropDownButton1.Name = "toolStripDropDownButton1"; 
     this.toolStripDropDownButton1.Size = new System.Drawing.Size(30, 22); 
     this.toolStripDropDownButton1.Text = "\\/"; 
     // 
     // itemToolStripMenuItem 
     // 
     this.itemToolStripMenuItem.Name = "itemToolStripMenuItem"; 
     this.itemToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 
     this.itemToolStripMenuItem.Text = "Item"; 
     // 
     // Form2 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.ClientSize = new System.Drawing.Size(763, 612); 
     this.Controls.Add(this.toolStrip1); 
     this.Name = "Form2"; 
     this.Text = "Form2"; 
     this.toolStrip1.ResumeLayout(false); 
     this.toolStrip1.PerformLayout(); 
     this.ResumeLayout(false); 
     this.PerformLayout(); 

    } 

    #endregion 

    public Form2() 
    { 
     InitializeComponent(); 
    } 

    private System.Windows.Forms.ToolStrip toolStrip1; 
    private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton1; 
    private System.Windows.Forms.ToolStripMenuItem itemToolStripMenuItem; 
} 

Windowsにこのメニューを左に描画させる方法はありますか?

enter image description here

答えて

3

ただ、ドロップダウンメニューがボタンに整列する方法を制御するボタンをDropDownDirectionを設定します。私はBelowLeftがあなたが探しているものだと思う。

toolStripDropDownButton1.DropDownDirection = ToolStripDropDownDirection.BelowLeft; 
+0

ええ、私はそれについて知っているが、もっと一般的な解決策を探していた。このドロップダウンの位置を自動的に調整するもの。 – greenshade

+0

ボタン自体が右揃えの場合、常にBelowLeftに行くのが賢明です。ボタンがツールストリップに浮いていて、ときどき右端にある場合は、DropDownOpening中にボタンの実際のRight座標を確認し、DropDownLocationを調整することが唯一の解決策だと思います。 –

関連する問題