Ermitteln der gedrückten Maustasten innerhalb der Click-Ereignisbehandlungsprozedur
Ermitteln der gedrückten Maustasten innerhalb der
'Click'-Ereignisbehandlungsprozedur
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=clickmousebuttons&lang=de>
----------------------------------------------------------------------------
Determining which mouse buttons are pressed in the 'Click' event handler
Although the 'e' parameter is typed as 'EventArgs' in the event handler's
signature, it contains a MouseEventArgs object exposing information about
the buttons being pressed when the event handler gets called. The code
sample below displays information about the mouse buttons when the user
clicks a form:
\\\
Private Sub Form_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Click
If TypeOf e Is MouseEventArgs Then
Dim Args As MouseEventArgs = DirectCast(e, MouseEventArgs)
MsgBox(Args.Button.ToString())
End If
End Sub
///
Some controls like the button control will only raise the 'Click' event if
the left mouse button is pressed and thus won't reveal this information for
clicks with other mouse buttons.