当前位置:萝卜系统下载站 > 技术开发教程 > 详细页面

MainMenu的Merge运用

MainMenu的Merge运用

更新时间:2022-07-06 文章作者:未知 信息来源:网络 阅读次数:

MainMenu Merge

windows form的程序使用菜单mainmenu是,有时需要根据操作隐藏或显示menuitem,另外窗体类和关联的菜单项事件在一个class中,结构清晰。

do like this:
class Form1: Form{
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
IsMdiContainer = true;
Menu = new MainMenu();
MenuItem File = Menu.MenuItems.Add("&File");
File.MergeType = MenuMerge.MergeItems;
File.MergeOrder = 0;
MenuItem FileNew = File.MenuItems.Add("&New", new EventHandler(New_Click));
FileNew.Shortcut = Shortcut.CtrlN;
FileNew.MergeOrder = 10;


}
private void New_Click(Object Sender,EventArgs e)
{

}
// other codes
}
public class doc : System.Windows.Forms.Form
{
public doc()
{
Menu = new MainMenu();
MenuItem File = Menu.MenuItems.Add("&File");
File.MergeType = MenuMerge.MergeItems ;
File.MergeOrder = 0;
MenuItem Save=File.MenuItems .Add ("&Save",new EventHandler (Save_Click));
Save.MergeType =MenuMerge.MergeItems ;
Save.MergeOrder =9;

MenuItem Saveas=File.MenuItems .Add ("&Save as",new EventHandler (Saveas_Click));
Saveas.MergeType =MenuMerge.MergeItems ;
Saveas.MergeOrder =11;

MenuItem Help = Menu.MenuItems.Add("&Help");
Help.MergeOrder = 400;
Help.MenuItems.Add("&About .NET Resourcer");
}
private void Save_Click(Object Sender,EventArgs e)
{

}
private void Saveas_Click(Object Sender,EventArgs e)
{
 MessageBox.Show ("Hello guys");
}
// other code
}

温馨提示:喜欢本站的话,请收藏一下本站!

本类教程下载

系统下载排行

网站地图xml | 网站地图html