ContextMenuStrip 和鼠标滚轮

发布于 2024-08-29 12:14:32 字数 122 浏览 15 评论 0原文

我有一个包含许多项目的 ContextMenuStrip。

如何处理鼠标滚轮滚动项目?

我在网上搜索但没有找到有用的东西。

或者如何从上下文菜单中获取第一个/最后一个显示/可见项目?

I have a ContextMenuStrip with many items.

How to handle mouse wheel to scroll throught items?

I search the net but nothing find usefull.

Or how to get first/last displayed/visible item from contextmenu?

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

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

发布评论

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

评论(3

独孤求败 2024-09-05 12:14:32

由于这是一个老问题,您可能不需要这个,但以防万一并供将来参考。
您可以模拟上下按键来滚动浏览它,它远非完美,但它比必须编写自己的ContextMenuStrip来处理滚轮。
鼠标滚轮滚动工具条菜单项

Since this is a old question you probably wont need this, but just in-case and for future reference.
You can simulate key up and down presses to scroll through it, its far from perfect but it beats having to write your own ContextMenuStrip to handle the scroll wheel.
Mouse wheel scrolling Toolstrip menu items

最笨的告白 2024-09-05 12:14:32

虽然这个问题很老了,但有人仍然可能从我的输入中受益......

var menu = new ContextMenuStrip();
menu.MouseWheel += (ob, ev) => SendKeys.SendWait(ev.Delta > 0 ? "{UP}" : "{DOWN}");

Although this question is very old, someone may still benefit from my input...

var menu = new ContextMenuStrip();
menu.MouseWheel += (ob, ev) => SendKeys.SendWait(ev.Delta > 0 ? "{UP}" : "{DOWN}");
微凉 2024-09-05 12:14:32

向 CMS 添加如此多的项目以至于需要滚动,这完全违背了上下文菜单的目的。不要设计难以使用且需要用户浏览数十个项目的 UI。您的用户会不喜欢您充满热情的编程,并会找出您住在哪里。

CMS 支持子菜单。对菜单项进行分类。

Adding so many items to a CMS that it requires to be scrolled completely defeats the purpose of a context menu. Don't design a UI that's hard to use and requires the user to scan through dozens of items. Your users will dislike you program with a passion and will find out where you live.

A CMS supports sub-menus. Categorize your menu items.

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