简体   繁体   English

即使在C#中的嵌套面板控件上也看不到MouseWheel

[英]Can't see MouseWheel even on nested Panel control in C#

I have a Panel on a TabPage on a TabControl that is on a form. 我在窗体上的TabControl的TabPage上有一个面板。

I have a Mouse Event function "control_MouseWheel". 我有一个鼠标事件函数“ control_MouseWheel”。

If I bind that function to the MouseWheel event of just the panel, nothing happens when I scroll the mousewheel. 如果我将该函数绑定到仅面板的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. 如果我将该函数绑定到面板和TabPage或所有三个面板,TabPage和TabControl的MouseWheel事件,则不会发生任何事情。

If I then bind that function to the MouseWheel event of the form, the mouse event handler fires, but only on the form. 如果然后将该函数绑定到窗体的MouseWheel事件,则将触发鼠标事件处理程序,但仅在窗体上触发。 I can see this via the use of ConsoleWriteline(). 我可以通过使用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? 我是否缺少子控件堆栈的属性设置?

The MouseWheel event is sent to the control that has focus. MouseWheel事件发送到具有焦点的控件。

Since panels cannot have focus, they will never get MouseWheel events. 由于面板无法获得焦点,因此它们将永远不会获得MouseWheel事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM