I can disable the main toolStripMenu items but not the items in the sub menus. For example I have a menu item called "Options" When I run the code below "Options" is disabled but none of the menu items under "Options" are disabled. Shouldn't this code be disabling all menu items for menuStrip1 including the sub menu items? Please help.
foreach (ToolStripMenuItem item in menuStrip1.Items)
{
item.Enabled = false;
}
The
Items
collection is not recursive; it onl;y includes direct children.If you want to loop over descendents, you'll need to run your loop again on the
Items
collection of each item.