.NET是否有可能有一个组合框的项目将ContextMenu? [英] .NET Is it possible to have a contextmenu on an item of a combobox?

查看:88
本文介绍了.NET是否有可能有一个组合框的项目将ContextMenu?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我有下拉列表中有多个项目。我想显示上下文菜单,当用户点击一个下拉列表项鼠标右键。这可能吗?如果有可能,怎么了?

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? And if it is possible, how?

推荐答案

由于的菜单项没有一个ContextMenu属性是不容易,因为它是与许多其他控件。你可能需要捕获右键单击事件,然后位置,并手动显示上下文菜单。

Since MenuItem doesn't have a ContextMenu property it isn't as easy as it is with many other controls. You'll probably need to capture the right-click event and then position and show the context menu manually.

虽然两个注意事项:

  • 组合框列表将关闭时 列表失去焦点,所以它可能会关闭 上下文菜单显示时 更让用户不清楚什么 他们(而不是100%肯定点击上 这一点,因为我没有写的 code测试。)

  • The combobox list will close when the list loses focus, so it may close when the context menu is shown leaving the user unclear as to what they clicked on (not 100% sure on this, since I haven't written the code to test.)

更​​重要的是我认为 这是一个糟糕的用户界面的选择,我 想不出任何真正的世界 有应用程序我用 右键菜单上的菜单项,所以它 不会很发现的 最终用户。另外上下文菜单的应该的 只是用于快速访问,他们 不应该访问的唯一方式 功能。你会成为 能够公开这些功能 通过其他方式以及右键菜单?

More importantly though I would argue that this is a poor UI choice, I can't think of any real world applications I've used that have context menus on menu items, so it wouldn't be very discoverable for the end user. Plus context menus should be just for quick access, they shouldn't be the only way to access functionality. Are you going to be able to expose these functions through other means as well as the right-click menu?

这篇关于.NET是否有可能有一个组合框的项目将ContextMenu?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆