Setting or removing an image for an item

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.


The image for an item can be set when an item is first
added to the list view control.

m_listctrl.InsertItem( LVIF_TEXT | LVIF_IMAGE, nRow, sItemText, 0, 0, nImage, NULL);

The image can later be changed by calling the SetItem() function. The CListCtrl
class does not have a SetImage() function.

m_listctrl.SetItem( 0, 0, LVIF_IMAGE, NULL, nImage, 0, 0, 0 );

To remove the image, use a value of -1 for nImage, else nImage should be
a zero based index of the image in the image list.

 

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read