ScrollableControl.OnMouseWheel(MouseEventArgs) 方法


引发 MouseWheel 事件。Raises the MouseWheel event.

 override void OnMouseWheel(System::Windows::Forms::MouseEventArgs ^ e);
protected override void OnMouseWheel (System.Windows.Forms.MouseEventArgs e);
override this.OnMouseWheel : System.Windows.Forms.MouseEventArgs -> unit
Protected Overrides Sub OnMouseWheel (e As MouseEventArgs)



包含事件数据的 MouseEventArgsA MouseEventArgs that contains the event data.


如果垂直滚动条是可见的,这意味着该 VScroll 属性设置为 true ,鼠标滚轮会 ScrollableControl 垂直滚动控件。If the vertical scroll bar is visible, which means that the VScroll property is set to true, the mouse wheel scrolls through the ScrollableControl control vertically. 但是,如果只有水平滚动条是可见的,这意味着,将 VScroll 设置为 false ,并将 HScroll 属性设置为 true, 在水平方向上滚动。However, if only the horizontal scroll bar is visible, which means that the VScroll is set to false and the HScroll property to set to true, the mouse wheel scrolls horizontally.

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 处理和引发事件For more information, see Handling and Raising Events.

OnMouseWheel 方法还允许派生类对事件进行处理而不必附加委托。The OnMouseWheel method also allows derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.


OnMouseWheel(MouseEventArgs) 在派生类中重写时,请确保调用基类的 OnMouseWheel(MouseEventArgs) 方法,以便注册的委托接收事件。When overriding OnMouseWheel(MouseEventArgs) in a derived class, be sure to call the base class' OnMouseWheel(MouseEventArgs) method so that registered delegates receive the event.