Export (0) Print
Expand All

MouseEventArgs Class

Provides data for the MouseUp, MouseDown, and MouseMove events.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[<ComVisibleAttribute(true)>]
type MouseEventArgs =  
    class 
        inherit EventArgs 
    end

The MouseEventArgs type exposes the following members.

  NameDescription
Public methodMouseEventArgsInitializes a new instance of the MouseEventArgs class.
Top

  NameDescription
Public propertyButtonGets which mouse button was pressed.
Public propertyClicksGets the number of times the mouse button was pressed and released.
Public propertyDeltaGets a signed count of the number of detents the mouse wheel has rotated, multiplied by the WHEEL_DELTA constant. A detent is one notch of the mouse wheel.
Public propertyLocationGets the location of the mouse during the generating mouse event.
Public propertyXGets the x-coordinate of the mouse during the generating mouse event.
Public propertyYGets the y-coordinate of the mouse during the generating mouse event.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The MouseDown event occurs when the user presses the mouse button while the pointer is over a control. The MouseUp event occurs when the user releases the mouse button while the pointer remains over the control. The MouseMove event occurs when the user moves the mouse pointer over a control. A MouseEventArgs specifies which mouse button is pressed, how many times the mouse button was pressed and released, the coordinates of the mouse, and the amount the mouse wheel moved.

It is possible to receive a MouseDown event without a corresponding MouseUp, if the user switches focus to another application before releasing the mouse button.

These three events exist for the Control, AxHost, and NotifyIcon classes.

For information about the event model, see Handling and Raising Events.

The following code examples handles the MouseDown event on a TextBox control so that clicking the right mouse button selects all the text in the control. This example requires that you have a form that contains a TextBox control that is named textBox1.

No code example is currently available or this language may not be supported.

The following code example uses the Location property to track clicks of the left mouse button and to draw a series of straight line segments in response to user input. The example does not redraw the lines if you hide the form and then redisplay it; this code has been omitted for simplicity.

No code example is currently available or this language may not be supported.

The following code example uses the X and Y properties to display the current position of the mouse pointer in a ToolTip window.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft