右键单击右侧样式菜单

发布于 2024-10-29 13:02:09 字数 277 浏览 6 评论 0 原文

目标:
有一个具有正确样式的右键菜单

问题:
当我右键单击时,我应该如何检索此样式:

Request to retreive this style

而不是此样式: 我想删除的当前样式

我正在使用组件 ContextMenuStrip 通过右键单击来显示菜单。

Goal:
Have a right click menu with a right style

Problem:
How should i retrieve this style when I'm right clicking:

Request to retreive this style

and not this style:
Current style that I would like to remove

I'm using the component ContextMenuStrip to display menu by right clicking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-11-05 13:02:09

您必须使用ContextMenuStrip rel="nofollow">上下文菜单。这是来自MSDN:

虽然 ContextMenuStrip 取代了以前版本的 ContextMenu 控件并为其添加了功能,但仍保留了 ContextMenu,以实现向后兼容和将来使用(如果您选择)。

我已经用一个原始示例对其进行了测试,它确实按照您的要求工作。请注意,使用ContextMenu您会失去一些设计器功能,并且必须在代码文件中手动设置一些属性。

在我的示例中,我将 ContextMenuStrip 更改为 ContextMenu 类型,将所有 ToolStripItem 对象更改为 MenuItem,将菜单绑定到表单的 < em>ContextMenu 属性并删除了所有大小设置(ContextMenu 不使用任何设置)。

Instead of using ContextMenuStrip, you have to use ContextMenu. This is from MSDN:

Although ContextMenuStrip replaces and adds functionality to the ContextMenu control of previous versions, ContextMenu is retained for both backward compatibility and future use if you choose.

I've tested it with a primitive example and it does work as you want. Please note, that using ContextMenu you lose some designer functionality and you have to manually set some properties in your code file.

In my example I changed ContextMenuStrip to ContextMenu type, all ToolStripItem objects to MenuItem, bound the menu to form's ContextMenu property and removed all size settings (ContextMenu does not use any).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文