I don't see anywhere you AddHandler to capture the click events.....
Ahhh.... I see it now....
You have the click event only linked to l. Each time l=new LinkLabel() fires, it resets the reference... which means as is, the l_Click will only capture the last instance of l that gets created.
See if this works for you:
Code:
DimWithEvents l As LinkLabel /* global variable
form_load event*/
Me.SuspendLayout 'Prevent time consuming repaints
Do
l = New LinkLabel()
Me.Controls.Add(l)
l.Text = "Account" & " " & dr1.Item("countrow") & " " & "from" & " " & dr1.Item("column1")
l.name = "L" & dr1.Item("countrow").ToString
l.Visible = True
l.Enabled = True
l.AutoSize = True
l.Top = t + 40
t = l.Top
AddHandler Me.Controls("L" & dr1.Item("countrow").ToString).Click, AddressOf l_Click
LoopWhile dr1.Read
Me.ResumeLayout 'force the repaint to show the updated form
PrivateSub l_Click(ByVal sender AsObject, ByVal e As System.EventArgs)
Dim f AsNew form1()
'In here you can check the name of Sender (besure to cast it first) to see which link label was clicked.
f.Show()
Me.Hide()
EndSub I think that's right...
The only thing I'm not 100% sure of is this line:
Me.Controls("L" & dr1.Item("countrow").ToString).Click
I think you may have to cast that as well, to get to the click even member.
Tg
Bookmarks