Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

HandledMouseEventArgs Class

Allows a custom control to prevent the MouseWheel event from being sent to its parent container.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public class HandledMouseEventArgs : MouseEventArgs

You will want to use HandledMouseEventArgs primarily when developing a control that needs to handle mouse wheel events itself, and prevent them from being seen by the control's immediate parent container. HandledMouseEventArgs is not passed directly by MouseEventHandler when it handles the MouseWheel event. Rather, MouseEventHandler uses a MouseEventArgs, which you must cast to a HandledMouseEventArgs in order to cancel an occurrence of MouseWheel.

The following code example demonstrates how to mark the mouse wheel event as handled in a custom control.

Public Class MouseWheelControl
    Sub New()
        ' Add initialization code for the control here.  
    End Sub 

    Protected Sub MouseWheelControl_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseWheel
        Dim Hme As HandledMouseEventArgs = e
        Hme.Handled = True 
        ' Perform custom mouse wheel action here.  
    End Sub 
End Class
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.