Solved

URGENT:  Displaying graphics in ListView

Posted on 2003-11-25
3
291 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now