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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

images in a listbox?

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
0
0
CA
Does vb have a control similar to a listbox
that would allow me to add images rather than text
In other words I want the ablity to add images to a listbox that the user can select
 
Try with LISTVIEW & IMAGELIST this control come in Microsoft Common Controls 6.0 (MSCOMCTL.OCX) load this two controls in you form, then Configure LISTVIEW as:

Properties\Image Lists\Icon Image Lists\Normal = ImageList1

and then use this code:

ImageList1.ListImages.Add 1, &quot;Pic1&quot;, LoadPicture(<You pic file (ex &quot;c:\pictures\mypicture.jpg&quot;)>)

ListView1.ListItems.Add 1, &quot;Pic1&quot;, , 1
 
great thanks
can the images in the listview be accessed by an index #
 
a 3'rd question about the listview control
I get an error with this code

Label1 = ListView1.ListIndex

it tells me that listview is not an array
the following code is how I load images into the list view


ImageList1.ListImages.Add 1, &quot;Pic1&quot;, LoadPicture(&quot;a:\Evil Empire.bmp&quot;)
ImageList1.ListImages.Add 2, &quot;Pic2&quot;, LoadPicture(&quot;a:\00003046.jpg&quot;)
ImageList1.ListImages.Add 3, &quot;Pic3&quot;, LoadPicture(&quot;a:\Lovers Rock.bmp&quot;)
ListView1.ListItems.Add 1, &quot;Pic1&quot;, &quot;ccc&quot;, 1
ListView1.ListItems.Add 2, &quot;Pic2&quot;, &quot;bbb&quot;, 2
ListView1.ListItems.Add 3, &quot;Pic3&quot;, &quot;aaa&quot;, 3
End Sub


any ideas why I am getting an error

what I want to do is have a user click on an image in the listview and display the index of that image in a label

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top