I need to use the ';ContextMenutrip'; in several pictureboxes, but I need to know which one the user has selected when pressing the right click.
How can I do it?How do I get the Right Click event in VB.NET?
You need to add codes to MouseClick event of ContextMenuStrip1 (double click on it and select MouseClick from above combobox).
In below code, you can add your code after declaration of TPic.
----- ----- ----- -----
Private Sub ContextMenuStrip1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ContextMenuStrip1.MouseClick
If e.Button = Windows.Forms.MouseButtons.Right Then
If TypeOf (sender) Is PictureBox Then
Dim TPic As PictureBox = CType(sender, PictureBox)
' do anything with TPic
' like: MsgBox TPic.name
End If
End If
End SubHow do I get the Right Click event in VB.NET?
It's a matter of checking which mouse button was clicked on the event:
Private Sub Button18_MouseDown(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn6a.MouseDown
Dim whichNote As String = CType(sender, Button).Tag
If e.Button = Windows.Forms.MouseButtons.Right Then
whichNote = whichNote %26amp; ';S';
End If
PlayNote(sender, whichNote, True)
End Sub
No comments:
Post a Comment