MAIN MENU SUB MENU -> Level 2 Menu1 SUB MENU 2 -> Level 2 Menu1 --> Level3 Menu1
foreach (Control ctrl in coll) { MenuStrip menustrip = ctrl as MenuStrip; if (ctrl.Text == "MenuStrip") { foreach (ToolStripMenuItem toolstripmenuitem in menustrip.Items) { foreach (ToolStripItem toolstripmenuitem in toolscriptmenuitem.DropDownItems) { MessageBox.Show(toolstripmenuitem.Text); } } } }
public void GetMenuItems(ToolStripItemCollection menuItems) { foreach (ToolStripMenuItem itm in menuItems) { Console.WriteLine(itm.Text); if (itm.HasDropDown) { GetMenuItems(itm.DropDownItems); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)