Solved

URGENT:  Displaying graphics in ListView

Posted on 2003-11-25
3
299 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 250 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 250 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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