Hi Scott,
You've got a Form with a Menu set up I presume.
Look at the code in the "Windows Form Designer generated code" region.
You'll see that every MenuItem which has others below it has them added to
the MenuItems collection of <that> MenuItem.
Eg,
Me.MenuItemHelp.Index = 2
Me.MenuItemHelp.MenuItems.AddRange _
(New MenuItem() {Me.MenuItemHelpAbout})
Me.MenuItem1HelpText = "Help"
Me.MenuItemAbout.Index = 0
Me.MenuItemAbout.Text = "About"
So a recursive tree walker starting with the MainMenu Control would be the
kind of thing you're after.
Public Sub GetMenuItemTree (oMenu As Menu, lstMenuItems As ListBox,
sPath As String)
sPath = sPath & "\"
Dim oMenuItem As MenuItem
For Each oMenuItem in oMenu.MenuItems
* lstMenuItems.Items.Add (sPath & oMenuItem.Text)
GetMenuItemTree (oMenuItem, lstMenuItems, sPath &
oMenuItem.Text)
Next
End Sub
Call it with your MainMenu.
Public Sub GetMenuItemTree (MainMenu1, lstMenuItems, "")
Note that the mainMenu does not have a Text property itself. This is why
the adding to the ListBox is done inside the loop. [A minor departure from
normal tree walking behaviour.]
If you don't want the full path, simply remove all instances of sPath.
Regards,
Fergus