0

Here's the setting,
I have many link labels in my form(I guess around 150 link labels). All of them will handle a click event, with the same condition when clicked. What are the possible solutions regarding to this problem. Because it's not good if I'll do it one by one.

Below is my code that will loop through all the link label's when form load:

For Each contr As Control In Me.Controls
    If TypeOf contr Is LinkLabel Then

    End If
Next

Thanks in advanced! ;)

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by GeekByChoiCe
1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
		For Each contr As Control In Me.Controls
			If TypeOf contr Is LinkLabel Then
				AddHandler CType(contr, LinkLabel).LinkClicked, AddressOf LinkLabel_LinkClicked
			End If
		Next
	End Sub

	Private Sub LinkLabel_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
		MsgBox(String.Format("linkLabel clicked! Name: {0}",CType(sender,LinkLabel).Name))
	End Sub
0

Haha,,you're great dude!! Thanks for this one,.It helps me a lot.,By the way, may I ask you a question?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.