Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi!

I have a ListControl with 3 columns. In the third column can be only two text value (OK or FAILED). I want to color this text according to that what is the result. If it is OK then it should be green and if it is FAILED then it should be red. I know i have to use NM_CUSTOMDRAW but i can't figure it out how to use it correctly (i can color the whole column or the whole line, but this isn't what i want), and i didn't find a solution neither.

Can someone please give me a useable solution?

Thanks in advance!

kampi
Posted
Updated 19-Feb-10 9:58am
v2

You may need to owner draw the control and then draw your text in the various colors you want. I'd feel sure there are articles on CP on how to do this.

Your tags are wrong, you can't use MFC if you're only using C.
 
Share this answer
 
Sorry Christian! I misstyped. I meant C++. Is it ok now? I searched everywhere i useable code, but i didn't found. I found only codes where every second line, or the third column, or the fourth line was colored. All code used prepaint, which isn't good for me, because, at the beginning the third column is empty. I paste the text, according to that, if the copy(that's what i'm doing) was succesfull or not, and so i can't use those codes.

kampi
 
Share this answer
 
MIDL
you can use NM_CUSTOMDRAW and get the specific row and column.
NMLVCUSTOMDRAW* lplvcd = (NMLVCUSTOMDRAW*)pNMHDR;
*pResult = CDRF_DODEFAULT ;
int iRow = lplvcd->nmcd.dwItemSpec;
int iCol = lplvcd->iSubItem;

if it is the row and column of the desired text, write the code to set the colour using
lplvcd->clrText = RGB value; 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900