实现效果:
知识运用:
ToolStripPanel控件的Dock属性 //获取或设置控件的停靠方式
public override DockStyle Dock { get;ser } //属性值:DockStyle枚举值 默认为N one
ToolStripButton对象的Join方法 // 将指定的ToolStrip添加的ToolStripPanel
public void Join ( ToolStrip toolStripToDrag )
实现代码:
private void Form1_Load(object sender, EventArgs e) { ToolStripPanel tsp_Top = new ToolStripPanel(); ToolStripPanel tsp_Bottom = new ToolStripPanel(); ToolStripPanel tsp_Left = new ToolStripPanel(); ToolStripPanel tsp_right = new ToolStripPanel(); tsp_Top.Dock = DockStyle.Top; tsp_Bottom.Dock = DockStyle.Bottom; tsp_Left.Dock = DockStyle.Left; tsp_right.Dock = DockStyle.Right; Controls.Add(tsp_Top); Controls.Add(tsp_Bottom); Controls.Add(tsp_Left); Controls.Add(tsp_right); tsp_right.Join(toolStrip1); }