How to add LinkLabel in a ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a ListBox filled with many lines of simply text
I want to make few lines be a LinkLabel

How can I do this

Thanks
 
Add a linklabel control to the controls collection of the listbox:

Dim olink As New LinkLabel
olink.Text = "Google"
olink.Links.Add(0, Len(olink.Text), "www.google.com")
ListBox1.Controls.Add(olink)

Add a handler for the LinkClicked event of the LinkLabel and add code to
navigate to the URL that's specified by the LinkLabel:

AddHandler olink.LinkClicked, AddressOf LinkClicked

Private Sub LinkClicked(ByVal sender As Object, _
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
System.Diagnostics.Process.Start(CStr(e.Link.LinkData))
End Sub

hope that helps..
Imran.
 
vince said:
I have a ListBox filled with many lines of simply text
I want to make few lines be a LinkLabel

You can set the listbox' 'DrawMode' to 'OwnerDraw*' and then draw the items
accordingly in the 'DrawItem' event.0
 
Thanks Imran
You have resolve my problem

Vince

Imran Koradia said:
Add a linklabel control to the controls collection of the listbox:

Dim olink As New LinkLabel
olink.Text = "Google"
olink.Links.Add(0, Len(olink.Text), "www.google.com")
ListBox1.Controls.Add(olink)

Add a handler for the LinkClicked event of the LinkLabel and add code to
navigate to the URL that's specified by the LinkLabel:

AddHandler olink.LinkClicked, AddressOf LinkClicked

Private Sub LinkClicked(ByVal sender As Object, _
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
System.Diagnostics.Process.Start(CStr(e.Link.LinkData))
End Sub

hope that helps..
Imran.
 
Back
Top