Creating a ListBox of images?

蹲街弑〆低调 提交于 2019-12-10 15:20:12

问题


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:

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


回答1:


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




回答2:


  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.


来源:https://stackoverflow.com/questions/4205531/creating-a-listbox-of-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!