Search code examples
winapimfcclistctrl

CListCtrl - get the length of the item text


I'm deriving from CListCtrl. Is there a way to find out how long the text contained in item i subitem 0 (first column) is? That info is required by GetItemText().


Solution

  • There are 2 overloads for GetItemText(), you should use the one with 2 params. Like this:

    CString txt = CListCtrl::GetItemText(item, column);
    

    http://msdn.microsoft.com/en-us/library/cbtzx5b1%28v=vs.100%29.aspx