0

I have a ListBox displaying machine names. I want to display image icons beside each item in the ListBox, i.e. play the image beside a machine which is connected and stop the image beside the machine which is not connected.

Dave Cousineau
  • 12,154
  • 8
  • 64
  • 80
Biswarup Dass
  • 193
  • 1
  • 5
  • 19
  • Can you share your code? – Mwigs Jul 23 '14 at 06:02
  • 1
    Try to use DataGridView instead of ListView. There is a `Picture Box Column` where u can show the image. – Shell Jul 23 '14 at 06:08
  • i just have a listbox where the items are being populated from a dictionary. – Biswarup Dass Jul 23 '14 at 06:09
  • But we are trying to tell you that better ways of getting what you want exists. They exist in the form of `DataGridView` or `ListView`. – Mwigs Jul 23 '14 at 06:10
  • ok. listview works same as a listbox but with extra features. is this what you are trying to say? @MarcusWigert – Biswarup Dass Jul 23 '14 at 06:12
  • Exactly, check [here](http://stackoverflow.com/questions/4703641/what-is-the-difference-between-listbox-and-listview) & [here](http://msdn.microsoft.com/en-us/library/system.windows.forms.listview(v=vs.110).aspx) for more info. – Mwigs Jul 23 '14 at 06:14
  • @MarcusWigert Thanks. Let me stabilize my project architecture by changing the listbox control to a listview control. Then am getting back to you regarding the image thing. – Biswarup Dass Jul 23 '14 at 06:17
  • possible duplicate of http://stackoverflow.com/q/472897/3761928 – Shell Jul 23 '14 at 06:27

1 Answers1

0

You should use ListView instead of ListBox control. It supports multiple types of columns and images as well.

Have a look at the following tutorials that will guide through the way to accomplish what you exactly need:

  1. A CodeProject Article
  2. An answer on StackOverFlow
Community
  • 1
  • 1
Shaharyar
  • 12,254
  • 4
  • 46
  • 66
  • 1
    How does this answer the question? Please extract vital information from the links and only use them as a reference, instead of simply saying: "Go [here](http://www.example.org)." – Mwigs Jul 23 '14 at 06:04
  • He is not using `ListView`, I don't know how is he populating it. In this case he will have to completely change his logic related to `listbox`. So it is not a specific problem but he needs guidance to complete solution which is provided into links. – Shaharyar Jul 23 '14 at 06:07
  • 2
    I clearly see your point and agree on it, but such guidance should be provided in the form of comments instead of as an answer. – Mwigs Jul 23 '14 at 06:09
  • @Shaharyar Thanks.I will refer to the links you suggested too. – Biswarup Dass Jul 23 '14 at 06:18