Re: Loop through menu items in a toolbar

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks Smokey

appreciate the help

Regards

Michael Bond

"Smokey Grindel" wrote:

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


"mabond" <mabond@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E8DB5A0B-6336-4187-8A5C-EF7BA54B52C1@xxxxxxxxxxxxxxxx
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




.



Relevant Pages

  • Re: Loop through menu items in a toolbar
    ... You are going to have to use recursion ... Private sub DigIntoMenu(byref currentItemOn as ToolStripMenuItem) ... Dim mnu As ToolStripMenuItem ...
    (microsoft.public.dotnet.languages.vb)
  • RE: ToolStripMenuItem.Enabled Property problem - BUG?
    ... Private Sub Form1_Load(ByVal sender As System.Object, ... Friend WithEvents ToolStripDropDownButton1 As ... It's drop down items are one enabled and one disabled toolstripmenuitem. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: 2 Toolstrips in einem MDI Form?
    ... Private TSMIa As ToolStripMenuItem ... Private WithEvents mnuAShow As ToolStripMenuItem ... Private Sub Form1_Load _ ... ByVal e As System.EventArgs _ ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • ToolStripMenuItem.Enabled Property problem - BUG?
    ... Private Sub Form1_Load(ByVal sender As System.Object, ... The following procedure is required by the Windows Form Designer ... It's drop down items are one enabled and one disabled toolstripmenuitem. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Attach handlers to ToolStripMenuItems. Got stacked, Please Help
    ... Sub RecurseItems ... For Each ToolStripMenuItemChild As ToolStripMenuItem _ ... do you want a MouseEnter ... code that will add event handlers for one level down. ...
    (microsoft.public.dotnet.languages.vb)