|
|
Title | Tell whether the Shift key is pressed during a mouse click in Visual Basic .NET |
Description | This example shows how to tell whether the Shift key is pressed during a mouse click in Visual Basic .NET. |
Keywords | mouse, MouseClick, Shift, click, mouse click, VB.NET |
Categories | Tips and Tricks, Miscellany |
|
|
Use My.Computer.Keyboard.ShiftKeyDown to see if the Shift key is down. (Note: This example was written in VB 2005.)
|
|
Public Class Form1
Private Sub Form1_MouseClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Me.MouseClick
If My.Computer.Keyboard.ShiftKeyDown Then
Me.Text = "Shift+Click"
Else
Me.Text = "Click"
End If
End Sub
Private Sub Form1_MouseDoubleClick(ByVal sender As _
Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles _
Me.MouseDoubleClick
If My.Computer.Keyboard.ShiftKeyDown Then
Me.Text = "Shift+DoubleClick"
Else
Me.Text = "DoubleClick"
End If
End Sub
End Class
|
|
|
|
|
|