tags:

views:

35

answers:

2

is it possible to have specific text in a listbox line to act like a hyperlink?

dim sLocation as string = "\\server\folder\subfolder\"
    LstOut.Items.Add("text text text" & sLocation)

I would like this to open in explorer.

This is not an ASP application, just a plain old winform.

+1  A: 

I googled you question and on Tek-Tips Forums it says:

I would create a datatable that contains the hyperlink text, and the actualy HREF. catch the onclick event of the list box, grab the record they clicked, and use system.diagnostics.process.start(HREF) to open the default browser to the link.

Kyra
+1 for the only response. But I have decided against this functionality.
Jim
A: 

One suggestion would be to monitor when the listbox's index is changed. When it's changed, check to see if the index you're looking at is the one that ultimately needs to open up explorer. You could use a process.start command to open up explorer. I'm thinking something along the lines of

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
   if (listBox1.selectedIndex = indexToLookFor) Then
      Process.start("explorer.exe", File_Path)
   End If
End sub

Now, if you wanted to have the text from the selected item act as a local link to another folder on the system, it would simply be a matter of using this call instead

 process.start("explorer.exe", listbox1.text)
AndyPerfect