I have some menus that contain many menuitems. Mouse wheel doesn't scroll them. I have to use the keyboard arrows or click the arrows at top and bottom. Is it possible to use the mouse wheel to scroll toolstrip menu items? Thanks
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I modified Mohsen Afshin's answer to click the up/down arrows instead of sending up/down key presses. My application had a
ContextMenuStrip
calledmenu
. Here's the code.In the initialization:
The ScrollMenu function:
I was having trouble getting the
mouse_event
function to click a specific location, so I moved the cursor, clicked, and then moved the cursor back. It doesn't seem the cleanest, but it works.A working solution:
Register for
MouseWheel
event of your form andDropDownClosed
event of your rootMenuStripItem
(here, rootItem) in theLoad
event of the formAdd the code for
Keyboard
class which simulate key pressesAdd the code for
DropDownOpened
,DropDownClosed
,MouseWheel
events:You can enable it application wide with this class:
This is very simply using a submenu (
ToolStripMenuItem
) of the context menu :Assuming using a
form1
(orUserControl
) and acontextMenuStrip1
: