Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make ListBox selections hyperlinks 1

Status
Not open for further replies.

bozic12

MIS
Jan 23, 2003
48
US
Hi all,
I have a listbox that is populated from values of an array. I would like to make each item of this listbox list, which is multiselect, a hyperlink to a picture file of the item. I think I would probably need to have the address of the picture as an attribute for each record in my excel table, so I could just reference to this cell for the address of the picture for each item, but I don't know how to make each selection in the list link to this address. I hope this is possible, and if not, hopefully someone has a suggestion around it. My code for populating the listbox is below. Thanks in advance,

Jeff

j = -1
p = 0
For i = 0 To NumBrands - 1
j = j + 1
If BrandChoices.Selected(j) = True Then
For n = 1 To NumAllBrands
If Brands(2, n) = SingBrands(j + 1) Then
WorkholdingChoices.WorkChoices.AddItem Brands(3, n)
p = p + 1
End If
Next
End If
Next
NumWorkholdings = p
 
You won't get the listbox entries to LOOK like hyperlinks (blue, underlined), but you can get the same functionality using the change event for the listbox. Define a range in your workbook with a table of the links in the same order as they appear in your listbox. Then you can use something like:

sub WorkChoices_Change
range("MyLinks").cells(workchoices.listindex+1,1).hyperlinks(1).follow
end sub

Rob
[flowerface]
 
Rob,
This does work, but I was hoping to have a different action. Ideally, I would like clicking on the item to show the picture different from the event of selecting the item in the list. Therefore, I would love to have clicking on the words of the item be the link to the picture and clicking on the checkbox next to it to select it. As of now, since I want the picture viewing different from item selection, I put your code suggestion in the WorkChoices_DblClick subroutine. I'm sure you can figure out that this allows a single click to select and a double click to view the picture of the item. If there is no way to set up the listbox as I described above, I suppose this will have to work. Thanks for your coding help and hopefully you or someone else can help me set up the listbox the way I ideally would like it!!
 
What you're trying to do runs contrary to how a listbox is designed to work - when you click on an entry, the entry gets selected. If that's not what you want, I don't think a listbox will work for you. The best approach depends on your application - how many links are there? If possibly many (too many to put on-screen), it complicates things.
Rob
[flowerface]
 
All i'm hoping to do is modify the list box so that a customer who is using the system can click to see a picture of the item before they select it in case the item description listed in the list box isn't enough info for them to determine whether they want to select it or not. For the purpose it serves, I actually need to use a listbox, I would just like to add a feature so the customer can view a picture of the item before they select it if they want to.
 
I see two solutions:
1) use an approach similar to the one I suggested above, with the understanding that the user will need to unselect the listbox item if it's not one he wants.
2) use a separate combobox with the same list, for the express purpose of viewing items before selecting them in the listbox.

Maybe some other smart experts here will have better solutions...
Rob
[flowerface]
 
Ok, I think I will just use a modification of your previous suggestion. Thank you for all your help and time Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top