Results 1 to 4 of 4

Thread: Get all menu's

  1. #1

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437

    Get all menu's

    Is there a way to start a loop and get all the Menu's and MenuItems on a form ???

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Try something like this..
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim m As Menu = Me.Menu
    3.  
    4.         RecursiveMenuSearch(m)
    5.  
    6.     End Sub
    7.  
    8.     Private Sub RecursiveMenuSearch(ByVal ParentMenu As Menu)
    9.  
    10.         If TypeOf ParentMenu Is MenuItem Then
    11.             Diagnostics.Debug.WriteLine(CType(ParentMenu, MenuItem).Text)
    12.         End If
    13.  
    14.         For Each mnu As Menu In ParentMenu.MenuItems
    15.             RecursiveMenuSearch(mnu)
    16.         Next
    17.  
    18.     End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Aah... bugger.

    I just spent 20 minutes trying to figure this one out. Here was my feeble attempt.

    VB Code:
    1. Dim objMItem As MenuItem
    2.  
    3.         For Each objMItem In Me.MainMenu1.MenuItems
    4.             Debug.Write("objmitem")
    5.             MessageBox.Show(objMItem.Text.ToString)
    6.         Next

    :feelingquitestupidrightnow:

  4. #4

    Thread Starter
    Hyperactive Member spoiledkid's Avatar
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    437
    many tx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width