Display Hyperlink on Listview

vuadapass

New member
Joined
Nov 25, 2011
Messages
1
Programming Experience
Beginner
I have some problem with Listview on WinForm.

I'am trying to make an ListView Subitem like a hyperlink, so i using this code:


Dim lvItem As ListViewItem
lvItem = frmMain.Items.Add("ListViewItem1")
lvItem.ImageKey = "Graph1"
lvItem.SubItems.Add("http://microsoft.com")
lvItem.SubItems(1).ForeColor = Color.Blue ' Doesn't work
lvItem.SubItems(1).Font.Underline = True ' Error : Property 'Underline' is 'ReadOnly'


but the fore color doesn't change to Blue and the Error list say Property Underline is ReadOnly.

And how can i detect the event when clicked on a listview subitem ?



Thank you.
 
You cannot change properties of a Font object. You have to create a new Font object with the desired values. Also, if you want subitems to look different to the items, you need to set UseItemStyleForSubItems to False.

Of course, you could just use a DataGridView, which is likely what you should have been using in the first place. It has a standard column type that supports hyperlinks.
 
Back
Top