Check which submenu item was clicked in context menu strip

后端 未结 5 546
别那么骄傲
别那么骄傲 2021-01-06 05:53

There is a ContextMenuStrip in a grid control.

I have named it as GridContextMenu.

The GridContextMenu is populated with 4 - 5 items using the following code

5条回答
  •  一生所求
    2021-01-06 06:29

    You can do something like this:

    private void SubmenuItem_Click(object sender, EventArgs e)
    {
        var clickedMenuItem = sender as MenuItem; 
        var menuText = clickedMenuItem.Text;
    
        switch(menuText) {
            case "Tiger":
               break;
    
            case "Lion":
              break;
             . ...
        }
    }
    

提交回复
热议问题