网格控件中有一个 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)
{
}
在这种情况下如何检查选择了哪个动物子菜单的情况?请分享答案。