Private Sub lbl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl1.Click
Me.mnu1.Show(Me.lbl1, Me.lbl1.PointToClient(Cursor.Position))
End Sub
Private Sub lbl2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl2.Click
Me.mnu2.Show(Me.lbl2, Me.lbl2.PointToClient(Cursor.Position))
End Sub
Private Sub lbl3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl3.Click
Me.mnu3.Show(Me.lbl3, Me.lbl3.PointToClient(Cursor.Position))
End Sub
Private Sub lbl4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl4.Click
Me.mnu4.Show(Me.lbl4, Me.lbl4.PointToClient(Cursor.Position))
End Sub
Private Sub lbl5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl5.Click
Me.mnu5.Show(Me.lbl5, Me.lbl5.PointToClient(Cursor.Position))
End Sub
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim listLabel As New List(Of Label)()
listLabel.AddRange(New Label() {Label1, Label2, Label3, Label4})
For Each lbl As Label In listLabel
AddHandler lbl.Click, AddressOf Label_Click
Next
End Sub
Private Sub Label_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentLabel As Label = sender
MsgBox(currentLabel.Name & " : " & _
currentLabel.PointToClient(Cursor.Position).ToString())
End Sub
End Class