Building on post #8
Code:Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load 'add handler LabelClicks for all of the labels For Each c In Me.Controls If TypeOf c Is Label Then AddHandler (DirectCast(c, Label).Click), AddressOf LabelClicks End If Next End Sub Private Sub LabelClicks(ByVal sender As System.Object, _ ByVal e As System.EventArgs) 'sender is the label clicked Debug.WriteLine(DirectCast(e, MouseEventArgs).X & " " & DirectCast(e, MouseEventArgs).Y) Dim PBpoint As Point = DirectCast(sender, Label).PointToScreen(PictureBox1.Location) 'at this point PBpoint has the coordinates to the location in the PictureBox Dim mea As MouseEventArgs = _ New MouseEventArgs(Windows.Forms.MouseButtons.Left, 1, PBpoint.X, PBpoint.Y, 1) PictureBox1_Click(sender, mea) End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles PictureBox1.Click Debug.WriteLine(DirectCast(e, MouseEventArgs).X & " " & DirectCast(e, MouseEventArgs).Y) End Sub




Reply With Quote