|
-
Feb 1st, 2005, 12:31 PM
#1
Thread Starter
Lively Member
adding links to a listbox [RESOLVED]
I have a program that searches a text file for a particular string and pulls some information to display in a listbox. That information can be used to build a url that I want to display in the listbox.
This is kind of what I want to do:
VB Code:
For Each dElement As String In dArray
link = "<a href=" + Chr(34) + "http://www.company.com/info.asp?info=" + dElement + Chr(34) + ">" + dElement + "</a>"
ListBox1.Items.Add(link)
Next
but it ends up just showing:
<a href="http://www.company.com/info.asp?info=1234">1234</a>
rather than have "1234" be a link.
I've looked at the link class, but when I try to do the "Imports System.Web.UI.MobileControls" the intellisense doesn't know what that is.
Any ideas on what I'm doing wrong?
Last edited by shadowfyre; Feb 1st, 2005 at 03:48 PM.
-
Feb 1st, 2005, 12:46 PM
#2
Re: adding links to a listbox
if you want to import System.Web.UI.MobileControls you have to make a reference to the web.dll in your project
-
Feb 1st, 2005, 01:08 PM
#3
New Member
Re: adding links to a listbox
Windows form example. It can be easly modified for web site.
...
' Windows Form Designer generated code
Dim ok As New SortedList
Dim okk As DictionaryEntry
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ok.Add("Link 1", "http://www.vbfan.com")
ok.Add("Link 2", "http://www.microsoft.com")
For Each okk In ok
Me.ListBox1.Items.Add(okk.Key)
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Process.Start(okk.Value)
End Sub
-------------------------------------------------------------------
Now, all you have to do is fill values from your text file.
VBfan.com
Non english site. Croatian Visual Basic.NET site.
-
Feb 1st, 2005, 03:18 PM
#4
Thread Starter
Lively Member
Re: adding links to a listbox
vbdotnetboy, as per usual, that thought hit me 3 minutes after I hit the post button.
So now I have:
VB Code:
For Each da As String In DArray
defLink.Text = da
defLink.NavigateUrl = "http://www.company.com/infolog.asp?info=" + da
ListBox1.Items.Add(defLink)
Next
Stepping through the code, the attributes get populated correctly, but the listbox displays "System.Web.UI.MobileControls.Link".
Hmmm... VBnetFan at first I didn't think your idea applied, but now I have an idea. Say that DArray is already sorted and I do:
VB Code:
For Each da As String In DArray
ListBox1.Items.Add(da)
Next
This populates the listbox. Then I could get the selectedindexchanged event to trigger it like this:
VB Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Process.Start("http://www.company.com/infolog.asp?info=" + sender.text)
End Sub
The problem is getting the text of the selected index. Any idea on how to do that?
-
Feb 1st, 2005, 03:46 PM
#5
Thread Starter
Lively Member
Re: adding links to a listbox
Got it, "ListBox1.SelectedItem", Duh!
VB Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Process.Start("http://www.company.com/infolog.asp?info=" + ListBox1.SelectedItem)
End Sub
Thanks guys.
-
Feb 1st, 2005, 04:05 PM
#6
Re: adding links to a listbox [RESOLVED]
just for the record... this is a windows app right??? I think everyone who posted thinks its an ASP.NET app
-
Feb 2nd, 2005, 03:47 AM
#7
Member
Re: adding links to a listbox [RESOLVED]
what is asp.NET ???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|