delete
delete

Reputation:

Creating a ListBox of images?

How can I create a ListBox control on my Winforms application that has images in an orderly fashion, just like it holds text?

I'd like the images to appear like this: alt text

Maybe I don't even need to use a ListBox. Maybe there's a better control out there for this purpose? Thanks!

Upvotes: 5

Views: 2945

Answers (2)

xpda
xpda

Reputation: 15813

  1. Load all your images into an imagelist, using a unique key for each image, such as a filename. Make sure you set the imagelist imagesize to the size of the images.
  2. Set the listview LargeImageList property to the imagelist you loaded.
  3. Assign the imagekey property of each listview item to the key that matches its image in the imagelist.
  4. Set the listview view style to view.largeicon.
  5. Profit.

Upvotes: 0

Tim Robinson
Tim Robinson

Reputation: 54764

You possibly want an owner-draw list box. There's an example on the MSDN page for the DrawItem event.

Upvotes: 1

Related Questions