ToolStripMenuItem mi0 = (contextMenuStrip1.Items[0] as ToolStripMenuItem); //mi0是一级菜单项
if (mi0.HasDropDownItems) //如果mi0有子项
{
foreach (ToolStripMenuItem item in mi0.DropDownItems)
{
//item. //二级菜单项
}
}
为动态创建的二级菜单绑定 mousedown事件, 在 mousedown事件中,写如下代码
if (e.Button == System.Windows.Forms.MouseButtons.Right) {
MessageBox.Show((sender as ToolStripMenuItem).Text);
}