Results 1 to 3 of 3

Thread: Mergin Menus

  1. #1

    Thread Starter
    Lively Member hbandarra's Avatar
    Join Date
    Aug 2002
    Location
    Lisbon, PT
    Posts
    66

    Mergin Menus

    When I Merge two main menus, the names are not overriden as I would like to be:

    for example:

    Code:
    menuA:
    File Edit Help
    a1   b1   c1
    a2   b2   c2
    
    menuB:
    Help
    c3
    
    menuA.MergeMenu(menuB) should be:
    File Edit Help
    a1   b1   c1
    a2   b2   c2
              c3
    
    but instead, I get:
    File Edit Help Help
    a1   b1   c1   c3
    a2   b2   c2
    Why is that? How do I get the desired behaviour?

    Thx!

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    This works

    Dim a1 As New MenuItem()
    Dim a2 As New MenuItem()
    Dim a3 As New MenuItem()
    Dim b1 As New MenuItem()
    Dim b2 As New MenuItem()

    a1.Text = "Edit"
    a2.Text = "Paste"
    a3.Text = "Copy"

    b1.Text = "Edit"
    b2.Text = "Cut"

    a1.MenuItems.Add(a2)
    a1.MenuItems.Add(a3)
    b1.MenuItems.Add(b2)

    a1.MergeMenu(b1)

    MainMenu1.MenuItems.Add(a1)
    'MainMenu1.MenuItems.Add(b1)
    Wind and waves resolves all problems.

  3. #3

    Thread Starter
    Lively Member hbandarra's Avatar
    Join Date
    Aug 2002
    Location
    Lisbon, PT
    Posts
    66
    Thanks, cim3!

    Based on your example, I've written the following working code:

    Code:
            Dim localMainMenu As MainMenu = GetLocalMainMenu()
            Dim remoteMainMenu As MainMenu = GetRemoteMainMenu()
    
            Dim remoteMenuItem As MenuItem
            For Each remoteMenuItem In remoteMainMenu.MenuItems
                Dim localMenuItem As MenuItem
                Dim localFound As Boolean = False
                For Each localMenuItem In localMainMenu.MenuItems
                    If localMenuItem.Text = remoteMenuItem.Text Then
                        localMenuItem.MergeMenu(remoteMenuItem)
                        localFound = True
                        Exit For
                    End If
                Next
                If localFound = False Then
                    localMainMenu.MenuItems.Add(remoteMenuItem)
                End If
            Next
    But, as you can see, this solution ignores any ordering or merging type defined by the menu items.
    Of course I could do it my self, but was'n it supposed to work wright just by doing:
    Code:
    localMainMenu.MergeMenu(remoteMainMenu)
    ?

    Thx!

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