我有功能区菜单和面板下面。而且我不会在单击功能区菜单中显示内容在Windows窗体中不同的不同按钮 [英] I Have Ribbon Menu And Below A Panel. And I Wont Show Content In Panel On Clicked Ribbon Menu Different- Different Button In Windows Form

查看:72
本文介绍了我有功能区菜单和面板下面。而且我不会在单击功能区菜单中显示内容在Windows窗体中不同的不同按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有功能区菜单和面板下方。并且我不会在点击的功能区菜单中显示不同的内容 - 窗口形式的不同按钮 -



我该怎么做.....请帮忙我...

i have ribbon menu and below a panel. and i wont show different- different content in panel on clicked ribbon menu different- different button in windows form .

how can i do this ..... please help me ...

推荐答案

您是否考虑过使用Ribbon控件?在我看来,你想要的这样的功能。有关如何使用非Microsoft Ribbon控件的一篇很好的CodeProject文章:[ ^ ]。另请参阅:[ ^ ]。对于WPF:[ ^ ]

在这种情况下,我不认为你想要一个下拉菜单,而是一个ToolStrip控件。所以,在你的表格上放一个ToolStrip控件,然后添加四个按钮。



注意:我没有使用任何这些功能区控件。



制作一个便宜的功能区界面:我建议您创建/设计一系列面板,每个单独的顶级ToolStripMenuItem一个面板,每个相同的大小和外观。当然,每个面板都会显示您希望特定Panel向用户呈现的功能的控件。



例如,创建名为PanelFile,PanelEdit的面板, PanelTools,PanelHelp等



在您设计时,您可以将这些面板展开在您的表格上,以便于与他们合作。



设置好所有面板后,再将它们全部选中,单击F4进入属性菜单,将其锚点属性设置为左+上+右。确保您希望用户在应用程序启动时看到的面板位于所有其他面板的顶部。



我将所有面板对齐代码,但你当然可以在设计时手动完成。



现在,浏览你的ToolStrip按钮并双击每一个,并在EventHandler中生成,把代码放到z顺序的前面。



因此,我的表单中的代码可能如下所示:
Have you thought about using a Ribbon Control ? It seems to me that what you want is functionality like that. There's a good CodeProject article on how to use a non-Microsoft Ribbon Control: [^]. Also see: [^]. For WPF: [^]
In this case, I don't think you want a drop-down Menu, but a ToolStrip Control. So put, a ToolStrip Control on your Form, and add four Buttons to it.

Note: I have not used any of these Ribbon Controls.

To make a "cheap" kind-of-a-ribbon interface: I suggest that you create/design a series of Panels, one Panel for each separate top-level ToolStripMenuItem, each of the same size, and appearance. Each panel will, of course, display Controls for the functionality you wish that specific Panel to present to the user.

For example, create Panels named: PanelFile, PanelEdit, PanelTools, PanelHelp, etc.

As you are designing, you can spread these Panels out on your Form for ease of working with them.

When you have all the Panels designed, then select them all, click F4 to get to the Properties menu, and set their Anchor properties to Left+Top+Right. Make sure that the Panel you wish the user to see when the Application starts is "on top" of all the other Panels.

I'd align all the Panels in code, but you could certainly do that manually at design time.

Now, go through your ToolStrip Buttons and double-click on each one, and in the EventHandler that is generated, put the code to bring the appropriate Panel to the front of the z-order.

So, the code in my Form might look something like this:
private Point panelInitialLocation;

 private void Form2_Load(object sender, EventArgs e)
 {
     // position all the Panels beneath the ToolStrip
     panelInitialLocation = new Point(0,toolStrip1.Bottom);

     PanelFile.Location = panelInitialLocation;
     PanelEdit.Location = panelInitialLocation;
     PanelTools.Location = panelInitialLocation;
     PanelHelp.Location = panelInitialLocation;

     // select the Panel the user will see when the application is started
     PanelFile.BringToFront();
 }

 // user clicks the File ToolStripButton on the ToolStrip
 private void tsBtnFile_Click(object sender, EventArgs e)
 {
     PanelFile.BringToFront();
 }

 private void tsBtnEdit_Click(object sender, EventArgs e)
 {
     PanelEdit.BringToFront();
 }

 private void tsBtnTools_Click(object sender, EventArgs e)
 {
     PanelTools.BringToFront();
 }

 private void tsBtnHelp_Click(object sender, EventArgs e)
 {
     PanelHelp.BringToFront();
 }


这篇关于我有功能区菜单和面板下面。而且我不会在单击功能区菜单中显示内容在Windows窗体中不同的不同按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆