![]() ![]() | ||
When the user clicks the "Black Books" link in the CreateLinkLabel example on the CD-ROM from the previous topic, I'll have the code bring up a new form with the explanatory text "Black Books are designed to meet all your computing needs." How do we determine which link in the link label the user clicked? We can get the text associated with the link with the e.Link.LinkData.ToString method like this, displaying a new form if warranted:
Private Sub LinkLabel1_LinkClicked(ByVal sender As Object, _ ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) LinkLabel1.Links(LinkLabel1.Links.IndexOf(e.Link)).Visited = True If (e.Link.LinkData.ToString() = "info") Then Dim InfoWindow As New Form2() InfoWindow.Show() End If End Sub
You can see this new link at work in Figure 5.17.
![]() ![]() | ||