Loop through menu items in a toolbar

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
 
S

Smokey Grindel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top