Windows Develop Bookmark and Share   
 index > Windows Forms General > Updating images from imagelist in listview
 

Updating images from imagelist in listview

I have a listview that has colored icons at the head of each row... based on application status I need to be able to change these images to different colors to a particular index on the listview. I have an image of each color in the ImageList

I have 4 icons in an imagelist... I was wondering how to reference each item and apply a new image to the listview for a particular index of listview item... This needs to happen dynamically... something like listviewitem.icon = imagelist[0] or omething like that.

The Item was created like....

ListViewItem item = new ListViewItem ( sName, 0 );

item.SubItems.Add ( "Manual" );

item.SubItems.Add ( "Manual" );

item.SubItems.Add ( "Waiting..." );

item.SubItems.Add ( "Waiting..." );

item.SubItems.Add ( " " );

item.SubItems.Add ( sURL );

item.SubItems.Add ( sTargetDirectory + sTargetFile );

listViewStatus.Items.Add ( item );

I'm thinkingthat sName, 0 is the item name in the column and 0 references the item int he imagelist. I need to be able to dynamically set this particular time with the samename, just a different image in the image list depending on what's going on in the app.

Thanks,

D

dl0haus  Monday, April 16, 2007 6:40 PM

Hi,

First you must set the SmallImagList property of the ListView to the ImageList you created.

Then u have just to use this line of code to change the image of a row :

MyListView.ItemsIdea.ImageIndex = n;

i : The index of the listview item

n : The index of the image starting from 0 to 3

HTH.

Hayder Marzouk

Hayder Marzouk  Monday, April 16, 2007 7:25 PM

Hi,

First you must set the SmallImagList property of the ListView to the ImageList you created.

Then u have just to use this line of code to change the image of a row :

MyListView.ItemsIdea.ImageIndex = n;

i : The index of the listview item

n : The index of the image starting from 0 to 3

HTH.

Hayder Marzouk

Hayder Marzouk  Monday, April 16, 2007 7:25 PM

You can use google to search for other answers

Custom Search

More Threads

• Navigating between forms and responding to function keys
• Error when closing a Form
• Cannot create a child list for field
• Title Not Displayed in a Popup Form
• Image Manipulation
• Closing one form from another form
• how to show message box only once in vb.net
• clear a cbo selection in vb.net 2005
• Semi transparent windows not appearing in Taskbar?!
• Combobox with two columns