0

フォームが 1 つあり、フォーム内にツールストリップ コントロールが 1 つあり、ToolStripMenuItem を動的に追加しています。私が欲しいのは、1つがいっぱいになったときに、アイテムが次の行にリストされることです。フォームの高さと幅を増やすためにこれを試しましたが、新しい行にアイテムを追加できませんでした。

 ToolStripItemCollection t_col = toolStripTaskBar.Items;
        int _howMany = t_col.Count;
        Rectangle mi_bounds = t_col[_howMany - 1].Bounds;
        if (this.Width < (mi_bounds.X + mi_bounds.Width))
        {
            int minimumFormHeight = 80;
            this.MinimumSize = new Size((mi_bounds.X + mi_bounds.Width), minimumFormHeight);

        }

私が何を望んでいるのか理解できない場合はお知らせください。

どうすればこれを達成できますか。ありがとうございました。

4

1 に答える 1

1

ToolStrip の LayoutStyle プロパティを使用できます。テーブルに設定し、レイアウト設定を変更する必要があります (行数と列数を指定します)。

次のように実行できます。

this.toolStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
var layoutSettings = (this.toolStrip1.LayoutSettings as TableLayoutSettings);
layoutSettings.ColumnCount = 3;
layoutSettings.RowCount = 3;

そして、ツールストリップに新しいアイテムを追加できます:

var item = new ToolStripMenuItem(string.Format("item{0}", this.toolStrip1.Items.Count + 1));
this.toolStrip1.Items.Add(item);
于 2013-07-12T07:41:41.250 に答える