Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am having the same problem as the person that posted this thread was having:

 

http://www.xtremedotnettalk.com/showthread.php?s=&threadid=74437&highlight=menu+item

 

Basically, I have a list of items in a listbox that are dynamically added to a submenu in a context menu. And the items add fine everytime. But, the submenu only expands once. If I go back to access it, the submenu just has an arrow and no menu pops up. The number of items in the submenu indicate that the menu is properly creating all of the new menu items, just not showing them.

 

From what I've seen in VB.NET so far, M$ really screwed up context menus.

 

Let me know if any of you have suggestions...

 

Also, check out my other thread:

 

http://www.xtremedotnettalk.com/showthread.php?s=&postid=374628#post374628

 

Thanks :(

Posted

Here is my code:

 

   Private Sub ContextMenu5_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu5.Popup
       If (lstPlaylist.Items.Count > 0) Then
           mnuPlaylist.Enabled = True
           mnuPlaylist.MenuItems.Clear()

           Dim i As Integer

           For i = 0 To lstPlaylist.Items.Count - 1
               mnuPlaylist.MenuItems.Add(MediaName, AddressOf PlaylistMenuHandler)
           Next

           For i = 0 To lstPlaylist.Items.Count - 1
               MediaName = lstPlaylist.GetItemText(lstPlaylist.Items.Item(i))
               mnuPlaylist.MenuItems.Item(i).Text = Mid(MediaName, 1, InStr(MediaName, "<") - 1)
           Next

           mnuPlaylist.MenuItems.Item(GetCurrentPlayingIndex).Checked = True
       Else
           mnuPlaylist.Enabled = False
       End If
   End Sub

   Protected Sub PlaylistMenuHandler(ByVal sender As Object, ByVal e As System.EventArgs)
       Dim item As MenuItem
       item = DirectCast(sender, MenuItem)

       AxWindowsMediaPlayer1.controls.playItem(AxWindowsMediaPlayer1.currentPlaylist.Item(item.Index))
   End Sub

 

It works fine once and fails every other time....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...