title: MFC: How to change color/boldness of inidividual rows of ListCtrl?
body: <p>Using MFC and Visual Studio 2010 C++.  I need a way to make certain individual rows of a CListCtrl stand out (however I do not want to use the built-in selection capability to highlight the rows).  It could be the color of the row background, or font weight, or possibly even an image (if that is performant).</p>
  
  <p>Ideally I want to know how to do this using the stock list control.  However, if this is not possible then let me know of a way using 3rd party code.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here's the code I ended up using:</p>
  
  <pre><code>void MyList::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
  {
      NMLVCUSTOMDRAW* cd = reinterpret_cast&lt;NMLVCUSTOMDRAW*&gt;(pNMHDR);
  
      *pResult = CDRF_DODEFAULT;
  
      switch( cd-&gt;nmcd.dwDrawStage)
      {
          case CDDS_PREPAINT:
              *pResult = CDRF_NOTIFYITEMDRAW;
              break;
  
          case CDDS_ITEMPREPAINT:
              {
                  int rowNumber = cd-&gt;nmcd.dwItemSpec;
                  bool highlightRow = (bool)GetItemData(rowNumber);
                  if (highlightRow)
                  {
                      COLORREF backgroundColor;
                      backgroundColor = RGB(255, 0, 0);
                      cd-&gt;clrTextBk = backgroundColor;
                  }
              }
              break;
  
          default:
              break;
      }
  }
  </code></pre>
  
  <p>In my case, I wasn't using the ItemData for anything, so I called SetItemData elsewhere with a boolean value to indicate whether the row should be highlighted.</p>