有在网格控件的ContextMenuStrip。
我已经将其命名为GridContextMenu。
所述GridContextMenu被填充有4 - 使用以下代码5项:
gridcontextMenu.Items.Add(new ToolStripMenuItem
{
Name = Plants,
Text = Plants,
Tag = Plants,
Width = 100,
Image = <image source is put here>
});
gridcontextMenu.Items.Add(new ToolStripMenuItem
{
Name = Animals,
Text = Animals,
Tag = Animals,
Width = 100,
Image = <image source is put here>
});
在工具条动物菜单,我以下面的方式加入的子菜单
(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Tiger", image_source, new EventHandler(SubmenuItem_Click));
(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Lion", image_source, new EventHandler(SubmenuItem_Click));
(gridcontextMenu.Items[1] as ToolStripMenuItem).DropDownItems.Add("Elephant", image_source, new EventHandler(SubmenuItem_Click));
在SubmenuItem_Click事件处理程序,我需要知道单击的动物子菜单。
如何实现这一目标?
目前,我有在以下方式的事件处理程序的代码:
private void SubmenuItem_Click(object sender, EventArgs e)
{
}
如何检查条件在此事件中是哪种动物的子菜单中选择? 请分享答案。