即使在 C# 中的嵌套面板控件上也看不到 MouseWheel
我在表单上的 TabControl 的 TabPage 上有一个面板。
我有一个鼠标事件函数“control_MouseWheel”。
如果我将该函数绑定到面板的 MouseWheel 事件,则当我滚动鼠标滚轮时不会发生任何事情。
如果我将该函数绑定到面板和 TabPage 或所有三个面板、TabPage 和 TabControl 的 MouseWheel 事件,则不会发生任何情况。
如果我随后将该函数绑定到表单的 MouseWheel 事件,则鼠标事件处理程序将触发,但仅在表单上触发。我可以通过使用 ConsoleWriteline() 看到这一点。
如何让它触发我真正想要使用鼠标滚轮事件的底层面板?
我是否缺少子控件堆栈的属性设置?
I have a Panel on a TabPage on a TabControl that is on a form.
I have a Mouse Event function "control_MouseWheel".
If I bind that function to the MouseWheel event of just the panel, nothing happens when I scroll the mousewheel.
If I bind that function to the MouseWheel event of both the panel and the TabPage or all three of the Panel, the TabPage and the TabControl, nothing happens.
If I then bind that function to the MouseWheel event of the form, the mouse event handler fires, but only on the form. I can see this via the use of ConsoleWriteline().
How do I get it to fire for the underlying panel that I actually want to use the mouse wheel event?
Am I missing a property setting for the stack of child controls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MouseWheel
事件被发送到具有焦点的控件。由于面板无法获得焦点,因此它们永远不会获得
MouseWheel
事件。The
MouseWheel
event is sent to the control that has focus.Since panels cannot have focus, they will never get
MouseWheel
events.