Log in

View Full Version : hyperlinks in listbox



talytech
03-10-2011, 10:38 AM
Is there a way to populate a listbox with hyperlinks where the value displayed in the listbox is not the actual web address? For example.

I'd like the value "Service Provider" to be displayed in the list box, but when they click on "Service Provider" it opens up to the web address associated with it.

Similar to how the label control displays whatever you want it to display but you specify the hyperlink address in the properties.

JP2112
03-10-2011, 12:05 PM
What I do is keep an array of hyperlinks that corresponds to an array of display names.

hyperlinks(0) = "http://..."
hyperlinks(1) = "http://..."
hyperlinks(2) = "http://..."

displaynames(0) = "name #1"
displaynames(1) = "name #2"
displaynames(2) = "name #3"

I populate the listbox with the display names. When the listbox is clicked, the index of the selected item will match the element in the hyperlinks array. Then you can use whatever method you prefer to visit the URL.