You can do this with the CustomDraw handler, ref: MSDN Developing Custom Draw Controls in Visual C ++ .
It is basically quite simple (and MSDN is quite long), but it boils down to the following:
add one of them to the usual place:
ON_NOTIFY_REFLECT (NM_CUSTOMDRAW, OnCustomDraw)
Then add this method to the class.
void CMyListView :: OnCustomDraw (NMHDR * nmhdr, LRESULT * result)
{
LPNMLVCUSTOMDRAW vcd = (LPNMLVCUSTOMDRAW) nmhdr;
switch (vcd-> nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
{
* result = CDRF_NOTIFYITEMDRAW;
break;
}
case CDDS_ITEMPREPAINT:
{
vcd-> clrText = RGB (255,0,255); // change the color of the second row.
* result = CDRF_NOTIFYSUBITEMDRAW;
break;
}
default:
* result = 0;
break;
}
return
}
source share