CListCtrl icons in subitems??

Posted on 2004-08-16
Last Modified: 2013-11-20
I am trying to use a CListCtrl and I need one of my subitems to have an icon that changes based on dynamic data.  But for some reason I can only get it to show an icon in the far left item (assuming I don't drag a column).  As well as the icon does not change when I set the item using a different image index.  Anyone have any ideas about what I am doing wrong??  Has anyone done something simiar??  

Code snippits below:

  I have a dialog with a CListCtrl on it and here is how I am setting it up:

  HICON hIcon;
  hIcon = m_pMain->LoadIcon(IDI_ICO_UP);
  hIcon = m_pMain->LoadIcon(IDI_ICO_DOWN);



//Insert columns here...

I am inserting an item into the list like this:

  //insert our new item

every time the data changes I update the subitems like this:

      bool bret = m_lstFavMonitor.SetItem(iItem,4,LVIF_TEXT,newString,0,0,0,NULL);
    else if((pUpdate->GetLastPrice())>(pUpdate->GetOpenPrice()))
       bool bret = m_lstFavMonitor.SetItem(iItem,4,LVIF_TEXT,newString,1,0,0,NULL);


I am using WinXP SP1 and VS.NET 2003.


Question by:Jedimaster
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
LVL 55

Accepted Solution

Jaime Olivares earned 200 total points
ID: 11813288
You cannot use icons for second or third column with standard CListCtrl, but you can use any derived classes of codeproject:
LVL 39

Expert Comment

ID: 11814503
>> As well as the icon does not change when I set the item using a different image index.  

To change the icon of a Listcontrol you have to set  the iImage argument and set LVIF_IMAGE when calling SetItem:

(as you did load only 2 icons, you may have iImage == 0 or iImage == 1 BUT NOT iImage == 2 (????)

>> But for some reason I can only get it to show an icon in the far left item

Yes, standard CListCtrl  has one icon per row (and nozt per item).

Regards, Alex

LVL 44

Expert Comment

ID: 11818220
Owner draw / custom draw.  There you have to display the contents of the row/col so you can display what you want.  (It's not that difficult to do)

Featured Post

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 112
wordappend challenge 8 223
Not needed 13 129
Authenticate using sesu from script 7 113
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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