下面的代码示例演示如何将 ToolStripContainer 和 ToolStrip 添加到 Windows 窗体,将项添加到 ToolStrip,并将 ToolStrip 添加到 ToolStripContainer 的 TopToolStripPanel。using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; public class Form1 : Form { private ToolStripContainer toolStripContainer1; private ToolStrip toolStrip1; public Form1() { InitializeComponent(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } private void InitializeComponent() { toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); toolStrip1 = new System.Windows.Forms.ToolStrip(); // Add items to the ToolStrip. toolStrip1.Items.Add("One"); toolStrip1.Items.Add("Two"); toolStrip1.Items.Add("Three"); // Add the ToolStrip to the top panel of the ToolStripContainer. toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1); // Add the ToolStripContainer to the form. Controls.Add(toolStripContainer1);
哇塞恭喜。 顺便帮你找了一下问题答案。^_^ToolStripContainer 由控件每一侧的可扩展和可折叠的 ToolStripPanel 以及一个中间 ToolStripContentPanel 组成。使用 ToolStripPanel 来容纳一个或多个 ToolStrip、MenuStrip 或 StatusStrip 控件。使用中间 ToolStripContentPanel 来容纳其他控件。 通过分别将它们的 TopToolStripPanelVisible、BottomToolStripPanelVisible、LeftToolStripPanelVisible 和 RightToolStripPanelVisible 属性设置为 false,可以隐藏顶部面板、底部面板、左面板和右面板。默认情况下,这些属性的每一个在设计时都是 true。在设计时,ToolStripContainer 还显示其顶部面板已经展开。示例 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; public class Form1 : Form { private ToolStripContainer toolStripContainer1; private ToolStrip toolStrip1; public Form1() { InitializeComponent(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } private void InitializeComponent() { toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); toolStrip1 = new System.Windows.Forms.ToolStrip(); // Add items to the ToolStrip. toolStrip1.Items.Add("One"); toolStrip1.Items.Add("Two"); toolStrip1.Items.Add("Three"); // Add the ToolStrip to the top panel of the ToolStripContainer. toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1); // Add the ToolStripContainer to the form. Controls.Add(toolStripContainer1);
} }
用网络四国语言祝大你圣诞,元旦双节快乐: 汉语版:祝你天天快乐! 英语版:happy everyday to you! 俄语版:买个萝卜切吧切吧炖了吧! 日语版:锅你得洗哇
呵呵,没人回答问题噢。
恭喜先。
那个没有用过,
呵呵,小弟不才啊
可以上Google 上搜下,
ToolStripContainer 参考
http://www.cnblogs.com/hzuIT/articles/691157.html
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private ToolStripContainer toolStripContainer1;
private ToolStrip toolStrip1; public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
} private void InitializeComponent()
{
toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
toolStrip1 = new System.Windows.Forms.ToolStrip();
// Add items to the ToolStrip.
toolStrip1.Items.Add("One");
toolStrip1.Items.Add("Two");
toolStrip1.Items.Add("Three");
// Add the ToolStrip to the top panel of the ToolStripContainer.
toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1);
// Add the ToolStripContainer to the form.
Controls.Add(toolStripContainer1);
}
}
上下左右四个面板可以放工具栏、菜单、状态栏,中间的面板放一些窗体控件。
可以控制上下左右四个面板的显示隐藏。
请参考:
http://msdn.microsoft.com/zh-cn/library/ms229623(VS.80).aspx
顺便帮你找了一下问题答案。^_^ToolStripContainer 由控件每一侧的可扩展和可折叠的 ToolStripPanel 以及一个中间 ToolStripContentPanel 组成。使用 ToolStripPanel 来容纳一个或多个 ToolStrip、MenuStrip 或 StatusStrip 控件。使用中间 ToolStripContentPanel 来容纳其他控件。 通过分别将它们的 TopToolStripPanelVisible、BottomToolStripPanelVisible、LeftToolStripPanelVisible 和 RightToolStripPanelVisible 属性设置为 false,可以隐藏顶部面板、底部面板、左面板和右面板。默认情况下,这些属性的每一个在设计时都是 true。在设计时,ToolStripContainer 还显示其顶部面板已经展开。示例
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private ToolStripContainer toolStripContainer1;
private ToolStrip toolStrip1; public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
} private void InitializeComponent()
{
toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
toolStrip1 = new System.Windows.Forms.ToolStrip();
// Add items to the ToolStrip.
toolStrip1.Items.Add("One");
toolStrip1.Items.Add("Two");
toolStrip1.Items.Add("Three");
// Add the ToolStrip to the top panel of the ToolStripContainer.
toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip1);
// Add the ToolStripContainer to the form.
Controls.Add(toolStripContainer1);
}
}