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

后端 未结 6 1596
迷失自我
迷失自我 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:25

    As Wim said in his post, there's not a direct way to do this because the messages you want aren't fired.

    As a comprise, you could try setting DropdownStyle=Simple; on the Combo and shrink the scroll region to show a single line:

    http://img34.imageshack.us/img34/1695/49557147.jpg

    If you assign the Combo a context menu, it will open when the scroll region is right-clicked. You'd probably have to figure out what item was right-clicked. But as other have said, this doesn't sound like a standard Windows way or an intuitive use.

    Or how about a modal dialog that you could bring up from the Combo's context menu? On the dialog, you could have a list that the user could select from and a Delete button to delete the selected item(s).

提交回复
热议问题