Strange Context Menu Behavior Please help

P

PJ Olson

I have a context menu associated with a tray icon. On the context menu, I
have a menuitem that is populated with sub menuitems at run time. When the
user right-clicks the tray icon I populate the sub menuitems with the
following code:

Private Sub cmTray_Popup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmTray.Popup

miPresets.MenuItems.Clear()

Dim rb As New Windows.Forms.RadioButton

Dim mip As New MenuItem

For Each rb In gbPresets.Controls

If rb.Tag <> "" Then

mip.MenuItems.Add(rb.Text & " - " & rb.Tag, AddressOf mi_Click)

End If

Next

miPresets.MergeType = MenuMerge.Add

miPresets.MergeMenu(mip)

miPresets.Text = "Presets"

End Sub

This code works the first two times the context menu is popped up. After
that, the sub-menu items never appear again.

Can anyone help with this?

Thanks,
PJ
 
H

Herfried K. Wagner [MVP]

PJ Olson said:
I have a context menu associated with a tray icon. On the context menu, I
have a menuitem that is populated with sub menuitems at run time. When the
user right-clicks the tray icon I populate the sub menuitems with the
following code: [...]
This code works the first two times the context menu is popped up. After
that, the sub-menu items never appear again.

Does the code get executed a 2nd time? Add breakpoints and watch the variables.
 
P

PJ Olson

No, each time I right-click on the tray icon the code is executed once.

PJ


Herfried K. Wagner said:
PJ Olson said:
I have a context menu associated with a tray icon. On the context menu, I
have a menuitem that is populated with sub menuitems at run time. When the
user right-clicks the tray icon I populate the sub menuitems with the
following code: [...]
This code works the first two times the context menu is popped up. After
that, the sub-menu items never appear again.

Does the code get executed a 2nd time? Add breakpoints and watch the variables.
 
P

PJ Olson

No, each time I right-click on the tray icon the code is executed once.

PJ


Herfried K. Wagner said:
PJ Olson said:
I have a context menu associated with a tray icon. On the context menu, I
have a menuitem that is populated with sub menuitems at run time. When the
user right-clicks the tray icon I populate the sub menuitems with the
following code: [...]
This code works the first two times the context menu is popped up. After
that, the sub-menu items never appear again.

Does the code get executed a 2nd time? Add breakpoints and watch the variables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top