开发者

Making specific text a hyperlink

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" & sLoc开发者_StackOverflow中文版ation)

I would like this to open in explorer.

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


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.


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜