0

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;               
 }
News Reader
  • 79
  • 2
  • 8

1 Answers1

1

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.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964