Thanks again for your help. I think I'm getting close. As you suggest, I
handle the popup event of the *parent* of mnuTopics_Show, and, find the
'Show Type' menu option, then add the sub menu options. All works fine the
first time I access the sub menu items. But, for some reason, the sub menu
items do not appears on subsequent accesses. Here's the code:
Private Sub mnuTopics_Popup( _
ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics.Popup
' All of the code in this sub is dedicated to populating the
sub-menu-items
' of the 'Show Type' menu option:
' get the parent of 'Show Type' menu item:
Dim mMenu As Menu
mMenu = DirectCast(sender, Menu)
' Cycle through all of its options to find the 'Show Type' sub menu
option:
Dim mItem As MenuItem
For Each mItem In mMenu.MenuItems
If mItem.Text.ToString = "Show Type" Then
mItem.MenuItems.Clear()
Dim mSubMenuItem As MenuItem
' Add first sub menu item.
mSubMenuItem = New MenuItem()
mSubMenuItem.Text = "Sub Item #1"
mSubMenuItem.Enabled = True
mSubMenuItem.Visible = True
AddHandler mSubMenuItem.Click, AddressOf MenuClickhandler
mItem.MenuItems.Add(mSubMenuItem)
' Add second sub menu item.
mSubMenuItem = New MenuItem()
mSubMenuItem.Text = "Sub Item #2"
mSubMenuItem.Enabled = True
mSubMenuItem.Visible = True
AddHandler mSubMenuItem.Click, AddressOf MenuClickhandler
mItem.MenuItems.Add(mSubMenuItem)
End If
Next
End Sub
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ea*************@tk2msftngp13.phx.gbl...
"tmaster" <le*******@travelmasterusa.com> schrieb I get the same results.
The 'Select' event will show one sub menu item if only one if Added.
It shows neither when two are Added.
The 'Popup' event shows niether one nor two sub options, when they
are Added.
The 'Click' event shows niether one nor two sub options, when they
are Added.
Is there something else I could be doing incorrectly?
Sorry, my mistake! Handle the popup event of the *parent* of
mnuTopics_Show. Reason: mnuTopics_Show is shown when it's parent is opened. There you have
to fill the sub menu items of mnuTopics because the arrow is painted
depending on the count of visible sub menu items.
But, you have to change the code because you don't want to add the sub
menu items to the parent but to mnuTopics_Show itself. I tested it and it
works.
If mnuTopics has no parent, it should work when handling it's popup event.
Also tested this time.
--
Armin
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html