.NET Is it possible to have a contextmenu on an item of a combobox?

后端 未结 6 1597
迷失自我
迷失自我 2021-01-20 04:42

In my application I have dropdown list with several items. I\'d like to show a context menu when the user clicks the right mouse button on a dropdown item. Is this possible?

6条回答
  •  余生分开走
    2021-01-20 05:08

    For those asking "Why?" or saying they've never seen a combobox with a contextmenu; Look at any web browser's favorites dropdown. You can right click and delete, edit, or go to the entry in current tab, new tab, or new window. I also could not get an actual contextmenustrip to show, so I made a menu with a small borderless form and call with:

    Private Sub FavoritesBar_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles FavoritesBar.SelectedIndexChanged
        FavIndex = FavoritesBar.SelectedIndex 'FavIndex is declared as a public string.
        Dim Loc As Point = New Point(MousePosition)
        FavMenu.Location = Loc
        FavMenu.ShowDialog()
    End Sub
    

    With a homemade contextmenu, be sure to add "me.close" at the end of each sub as well as the me.mouseleave event.

提交回复
热议问题