tags:

views:

41

answers:

1

Hi!

I have a listcontrol with three columns. I want to read what text is in the third column. I need this, because i want color this column according to that what text is in it. Can anyone tell me, how to read the data?

Thanks in advance!

kampi

+1  A: 

If your control's associated CListCtrl is called m_listCtrl simply use:

CString colText = m_listCtrl.GetItemText(item, subitem);

You associate that variable with the control itself via something like this:

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, m_listCtrl);
}
Brian R. Bondy
Hi! Thank you very much! It's working fine! But now i have an other problem. Hope you can answer this too. If i want to use SetTextColor then it pastes my text with the color i want, but if i click on a row, or scroll it down then it will color the full row, and eventually everything will be colored. How can i color only the third column(according what text is in it)? Thanks in advance!
kampi
@kampi: Please post this as a new question since it is not related to the original asked question and subject.
Brian R. Bondy
Hi! I already did post this as a new question but i didn't get a usefull answer :( http://stackoverflow.com/questions/2282621/how-to-insert-colored-text-int-a-listview
kampi
Thanks I was going to answer it but someone beat me to it. You have to do the painting yourself. Unfortunately there is no very easy solution. Edit: I posted an answer though anyway with an already implemented class that I think does that.
Brian R. Bondy