views:

598

answers:

3

I am trying to display a thumbnail inside a listbox in a Windows Form application. I've read around and seen all sorts of suggestions, but I'm looking for the simplest one. Here's the details of what I'm trying to do.

I am trying to display a thumbnail of an image AND display text next to it.

I've looked at ListViews and they don't seem to offer what I am looking for. Any code would be appreciated.

A: 

set your listbox to ownerdraw

then in the itemdraw event (or is it drawitem?) grab your image and draw it in the space allotted (e.Graphics.DrawImage), then draw the test of the item next to it (e.Graphics.DrawString)

Boo
This is the correct approach, but you'll also have to handle drawing the item when it's in various states (selected, highlighted, etc.)
NascarEd
Thanks, Ed, for the additional detail. Very helpful.
Boo
+1  A: 

There are lots of implementations of an ImageListBox. One can be found here: http://www.codeproject.com/KB/combobox/imagelistbox.aspx

VVS
+1  A: 

Assign an image list to the ListBox and set the View property to: List or Tile, now for each item choose which image from the list should be displayed. Looks exactly like ListBox with images to me ;)

bbmud
This would be a ListView rather than a ListBox.
Tim Robinson