You could also define a click event for just one of the controls in the set then use AddHandler on form load to add the other controls to that handler. It would save a lot of clicking. You would have to modify the original handler to distinguish between the controls. Or, if you don't mind some cut and paste you could add them as follows:
Private Sub lbl01_Click(sender As System.Object, e As System.EventArgs) Handles _
lbl01.Click,lbl02.Click,lbl03.Click,lbl04.Click,...
Just extend the line for as many controls as you have. This gets a little messy, however, if you have a lot of controls. I recommend the AddHandler method.
Reverend Jim
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
Try this. I created a form with five labels and one listbox.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
AddHandler Label1.Click, AddressOf Label_Click
AddHandler Label2.Click, AddressOf Label_Click
AddHandler Label3.Click, AddressOf Label_Click
AddHandler Label4.Click, AddressOf Label_Click
AddHandler Label5.Click, AddressOf Label_Click
End Sub
Private Sub Label_Click(sender As System.Object, e As System.EventArgs)
Dim label As Label = sender
ListBox1.Items.Add(label.Text)
End Sub
End Class
Reverend Jim
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159