private void FormUI_Load(object sender, EventArgs e)
{
//实例化一个MenuStrip对象
MenuStrip myMenuStrip = new MenuStrip();
//实例化*菜单"文件","帮助"
ToolStripMenuItem menu_file = new ToolStripMenuItem("文件(&F)");
//ToolStripMenuItem menu_help = new ToolStripMenuItem("帮助(&H)");
//实例化文件菜单的子菜单"打开","保存"
ToolStripMenuItem menuitem_open = new ToolStripMenuItem("打开(&O)");
ToolStripMenuItem menuitem_save = new ToolStripMenuItem("保存(&S)");
menuitem_open.Click += OpenOToolStripMenuItem_Click;
menuitem_save.Click += SaveSToolStripMenuItem_Click;
//将"打开","保存"子菜单添加到文件*菜单下面
menu_file.DropDownItems.AddRange(new ToolStripMenuItem[] { menuitem_open, menuitem_save });
//将*菜单"文件"添加到MenuStrip中
myMenuStrip.Items.Add(menu_file);
//将MenuStrip添加到窗体中
this.Controls.Add(myMenuStrip);
}
子菜单单击事件实现方式和控件方式一样,没有区别, 不再累述..