C#菜单在窗体上不可用 [英] C# Menus are not vivible on the form

查看:49
本文介绍了C#菜单在窗体上不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我写了一个代码用C#创建一个菜单".我遇到的问题是菜单不可见.但是代码以另一种形式工作.我不明白发生了什么.使菜单不可见吗?.如果有人可以给我提示,我将非常感激..

sameera

Hello!!

I wrote a code to create a "MENU" in C#.The problem i have is menu is not visible.But the code works in a another form.I can''t understand what has happened.Is there any option in the form to make invisible the menu??.I will be realy thankful if any one can give me a hint..

sameera

推荐答案

1)更改用户名:除非您真的喜欢垃圾邮件,否则切勿在任何论坛中发布您的电子邮件地址!如果有人回复您,您将收到一封电子邮件,通知您

2)您是否在菜单中添加了菜单? IE.您是否将Form.MainMenuStrip属性设置为菜单?

谢谢.
但是我仍然对那个特定的表格有这个问题..这是我在两个项目中使用的代码.一个正在工作,一个没有工作."
1) Change your username: Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know

2) Did you add the menu to the form? I.e. Did you set the Form.MainMenuStrip Property to the menu?

"Thanks.
But i still have that problem with that specific form..Here is the code which i used for both projects.One is working,one is not."
private void set_menus() {
    mnumain = new MainMenu();

    MenuItem proc1 = new MenuItem("&Test Procedure");
    proc1.MenuItems.Add(new MenuItem("&Before Pouring", new EventHandler(this.proc1BeforePouring_clicked)));
    proc1.MenuItems.Add(new MenuItem("&After Pouring", new EventHandler(this.proc1AfterPouring_clicked)));
    proc1.MenuItems.Add(new MenuItem("&Exit", new EventHandler(this.proc1Exit_clicked)));
    this.Menu = mnumain;
}
private void proc1BeforePouring_clicked(object sender, EventArgs e)
{

}
private void proc1AfterPouring_clicked(object sender, EventArgs e)
{

}
private void proc1Exit_clicked(object sender, EventArgs e)
{
    this.Close();
}



您需要将菜单项添加到菜单...



You need to add the menuitem to the menu...

proc1.MenuItems.Add(new MenuItem("&Exit", new EventHandler(this.proc1Exit_clicked)));
mnumain.MenuItems.Add(proc1);  //<<<----- ADD THIS LINE
this.Menu = mnumain;


这篇关于C#菜单在窗体上不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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