Loop through menu items in a toolbar

  • Thread starter Thread starter mabond
  • Start date Start date
M

mabond

Hi

I want to loop through the menu items (including sub menus) of a toolbar.

I'm using this at present
Dim mnu As ToolStripMenuItem
For Each mnu In Me.MenuStrip1.Items
'do something to menu item
Next
But it only gives me the top level menu items and not the ones that branch
off those

Can anyone suggest the better way to do this

Michael Bond
 
You are going to have to use recursion


something like (this is pseudo code)

Private sub DigIntoMenu(byref currentItemOn as ToolStripMenuItem)

for each item as ToolStripMenuItem in currentItemOn.Items

' do something

' Recurse
DigIntoMenu(item.Items)

next
end sub
 
Back
Top