MouseButtons Enumeration


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Specifies constants that define which mouse button was pressed.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

type MouseButtons

Member nameDescription

The left mouse button was pressed.


The middle mouse button was pressed.


No mouse button was pressed.


The right mouse button was pressed.


The first XButton was pressed.


The second XButton was pressed.

This enumeration is used by many classes, including AxHost, Control, DataGrid, Form, RadioButton, Splitter, StatusBar, and UpDownBase.

The following example demonstrates how to use the GetCharFromPosition method to obtain a character from the contents of a RichTextBox given its control coordinates. The example code uses coordinates located in the MouseEventArgs object passed as a parameter to the event handler to determine the location in the control to obtain the character. The character is then displayed in a MessageBox if it is not a space character. This example assumes that a RichTextBox control named richTextBox1 has been created and that the example code is connected to the MouseDown event of the RichTextBox.

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

The following example demonstrates using different mouse events to draw the path of the mouse on a Panel. A line segment is added to the GraphicsPath for each MouseMove and MouseDown events that occur. To update the graphics, the Invalidate method is called for the Panel on each MouseDown and MouseUp event. In addition, the graphic path is scrolled up or down when the MouseWheel event occurs. Additional mouse events, like MouseHover, are identified on screen as well. Also displayed on the screen is additional information about the mouse from the SystemInformation class.

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

.NET Framework
Available since 1.1
Return to top