How can i find out which dynamic link has been clicked on Visual Basic? I have some LinkLabels created dynamically according to a dataset, and i want to open a new form that contains the information from that dataset, but i need to know how to load the form according to the link clicked.. code below... //This function creates linklabels according to the rows in the datatable
Sub DynamicLabels()
Dim i As Integer
Dim x As Integer = 14
Dim y As Integer = 50
Dim tp As TabPage = tabControl1.TabPages(1)
If db.HasConnection() Then
If db.SQLDS IsNot Nothing Then
db.SQLDS.Clear()
End If
db.RunQuery("SELECT c.courseSubj AS Subject, c.courseNum AS CourseNum, r.className AS ClassName, t.tName AS Professor
FROM course c, classRoom r, teacher t, classroom_student u, student s
WHERE c.courseId=r.course_id AND t.teacherId=r.teacher_id AND s.studentId=u.student_id AND u.classroom_id=r.classId AND s.sUsername='" & Login.Usr.Text & "' ")
For i = 0 To db.SQLDS.Tables(0).Rows.Count - 1
ReDim MyLabel(db.SQLDS.Tables(0).Rows.Count)
y += 50
With MyLabel(i)
MyLabel(i) = New LinkLabel()
MyLabel(i).Name = "linklabel" & i.ToString
MyLabel(i).Location = New Point(x, y)
MyLabel(i).Size = New Size(700, 40)
MyLabel(i).Font = New Font("Microsoft Sans Serif", 14)
MyLabel(i).Text = String.Format(CType(db.SQLDS.Tables(0).Rows(i).Item("Subject"), String) & " " & CType(db.SQLDS.Tables(0).Rows(i).Item("CourseNum"), String) & " " & CType(db.SQLDS.Tables(0).Rows(i).Item("ClassName"), String) & ": " & CType(db.SQLDS.Tables(0).Rows(i).Item("Professor"), String))
AddHandler MyLabel(i).LinkClicked, AddressOf label_LinkClicked
End With
tp.Controls.Add(MyLabel(i))
Next
End If
End Sub
I want to load a new form containing some information from the dataset.