Reputation: 2161
I am trying to create a sub menu or cascading menu on the ContextMenuStrip in WinForm core.
contextMenuStrip1.Items.Clear();
contextMenuStrip1.Items.Add(new ToolStripMenuItem("UPPER MENU"));
MenuStrip submenu = new MenuStrip();
submenu.Items.Add(new ToolStripMenuItem("SUB MENU1"));
submenu.Items.Add(new ToolStripMenuItem("SUB MENU2"));
How do I add the sub menu to "UPPER MENU1"
Upvotes: 0
Views: 560
Reputation: 5266
The items have to be added to the DropDown
of the UPPER MENU
item, e.g:
var upperMenu = new ToolStripMenuItem("UPPER MENU");
upperMenu.DropDown.Items.Add(new ToolStripMenuItem("SUB MENU1"));
contextMenuStrip1.Items.Add(upperMenu);
Upvotes: 2