//动态生成菜单
private void button1_Click(object sender, System.EventArgs e)
{
//创建顶级菜单
MenuItem newItem = new MenuItem();
newItem.Text = "myMenuitem";
newItem.Index = this.mainMenu1.MenuItems.Count;
this.mainMenu1.MenuItems.Add(newItem);
//子菜单一
MenuItem newSubItem1 = new MenuItem();
newSubItem1.Text = "mysubitem1";
newSubItem1.Index = this.mainMenu1.MenuItems.Count;
newSubItem1.Click += new System.EventHandler(this.MyMenuClick);
newItem.MenuItems.Add(newSubItem1);
//子菜单二
MenuItem newSubItem2 = new MenuItem();
newSubItem2.Text = "mysubitem2";
newSubItem2.Index = this.mainMenu1.MenuItems.Count;
newSubItem2.Click += new System.EventHandler(this.MyMenuClick);
newItem.MenuItems.Add(newSubItem2);
}
请问如何实现MyMenuClick事件??
private void MyMenuClick(object sender, System.EventArgs e)
{
//如果是菜单一点进来的,显示"菜单一"
//如果是菜单二点进来的,显示"菜单二"
}