2013-07-12 3 views
0

하나의 양식과 내부 양식에 하나의 도구 막대 컨트롤이 있고 ToolStripMenuItem을 동적으로 추가하고 있습니다. 내가 원하는 것은 항목이 채워지면 항목이 다음 행에 나열되어야한다는 것입니다. 폼의 높이와 너비를 높이기 위해이 방법을 시도했지만 새로운 행에 항목을 추가하는 일은 발생하지 않았습니다.하나의 행이 ToolStrip 안에 채워지는 경우 ToolStripMenuItem을 새 행에 추가하십시오.

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

     } 

내가 원하는 것을 이해하지 못하면 알려 주시기 바랍니다.

어떤 제안을 어떻게 할 수 있습니까? 감사합니다.

답변

1

ToolStrip의 LayoutStyle 속성을 사용할 수 있습니다. 표로 설정하고 레이아웃 설정을 수정해야합니다 (행 및 열 수 지정).

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

을 그리고 당신은 ToolStrip에 새로운 항목을 추가 할 수 있습니다 :

이 같은 그것을 할 수

var item = new ToolStripMenuItem(string.Format("item{0}", this.toolStrip1.Items.Count + 1)); 
this.toolStrip1.Items.Add(item);