MouseButtonState Enumeration
.NET Framework 3.0
Specifies the possible states of a mouse button.
Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
The following example shows a mouse event handler that determines which buttons are currently pressed by checking the button state of each mouse button.
private void MouseDownHandler(object sender, MouseEventArgs e) { if (e.RightButton == MouseButtonState.Pressed) { MessageBox.Show("The Right Mouse Button is pressed"); } if (e.LeftButton == MouseButtonState.Pressed) { MessageBox.Show("The Left Mouse Button is pressed"); } if (e.MiddleButton == MouseButtonState.Pressed) { MessageBox.Show("The Middle Mouse Button is pressed"); } if (e.XButton1 == MouseButtonState.Pressed) { MessageBox.Show("The XButton1 Mouse Button is pressed"); } if (e.XButton2 == MouseButtonState.Pressed) { MessageBox.Show("The XButton2 Mouse Button is pressed"); } }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: