?
Solved

URGENT:  Displaying graphics in ListView

Posted on 2003-11-25
3
Medium Priority
?
305 Views
Last Modified: 2012-07-22
Is there an easy way to display graphics in a listView to the left of the items when it is in details mode?  I know there are a lot of third party ones out there, but I don't want to use any of them.  Is there a way to do this easily using the standard ListView?
0
Comment
Question by:jjacksn
  • 2
3 Comments
 
LVL 20

Assisted Solution

by:TheAvenger
TheAvenger earned 1000 total points
ID: 9823293
Review the SmallImageList property of the ListView class. There is also an example where you can see how to use it.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewclasssmallimagelisttopic.asp
0
 
LVL 2

Accepted Solution

by:
jrberg earned 1000 total points
ID: 10109139
This should do it for ya.

1) Establish an ImageList
 
  ImageList imageList = new ImageList();
  imageList.Images.Add( new Icon(@"c:\path\to\icon1") );
  imageList.Images.Add( new Icon(@"c:\path\to\icon2") );
  imageList.Images.Add( new Icon(@"c:\path\to\icon3") );


2) Attach the imagelist to your ListView
  listView.SmallImageList = imageList;

3) Add your list view items
  ListViewItem item1 = listView.Items.Add("item1");
  ListViewItem item1 = listView.Items.Add("item1");
  ListViewItem item1 = listView.Items.Add("item1");

4) Assign images to them by their insert index order first being 0 and 2nd being 1 and so forth.
  item1.ImageIndex = 0;
  item1.ImageIndex = 1;
  item1.ImageIndex = 2;

5) TA-DA!

You will have to work this into your program as you see fit but I hope this example is clear and easy to understand,
Jerry
0
 
LVL 2

Expert Comment

by:jrberg
ID: 10109148
TYPE-O, Step 3 and 4 have TYPE-O's :)  I forgot to make the ListViewItem's seperate I kept using item1 over and over :)  All better now.

3) Add your list view items
  ListViewItem item1 = listView.Items.Add("item1");
  ListViewItem item2 = listView.Items.Add("item2");
  ListViewItem item3 = listView.Items.Add("item3");

4) Assign images to them by their insert index order first being 0 and 2nd being 1 and so forth.
  item1.ImageIndex = 0;
  item2.ImageIndex = 1;
  item3.ImageIndex = 2;

Thanks,
Jerry
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question