?
Solved

URGENT:  Displaying graphics in ListView

Posted on 2003-11-25
3
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 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