title: Foreach every Subitem in a MenuStrip
body: <p>I want to get all the <code>SubItems</code> of my <code>MenuStrip</code>, So I can change them all at once.</p>
  
  <p>I'am trying things like the following, but they aren't working:</p>
  
  <pre><code>foreach (ToolStripMenuItem toolItem in menuStrip1.DropDownItems)
  {
        //Do something with toolItem here
  }
  </code></pre>
  
  <p>Can someone help me out coding a good <code>foreach loop</code> for getting all the <code>SubMenuItems(DropDownItems)</code> from the <code>MenuStrip</code>?</p>
  
  <p>EDIT now trying to work with the following <code>Recursive method</code>:</p>
  
  <pre><code>private void SetToolStripItems(ToolStripItemCollection dropDownItems)
          {
              try
              {
                  foreach (object obj in dropDownItems)
                  {
                      if (obj.GetType().Equals(typeof(ToolStripMenuItem)))
                      {
                          ToolStripMenuItem subMenu = (ToolStripMenuItem)obj;
  
                          if (subMenu.HasDropDownItems)
                          {
                              SetToolStripItems(subMenu.DropDownItems);
                          }
                          else
                          {
  
                          }
                      }
                  }
              }
              catch
              {
  
              }
          }
  </code></pre>