请教高手怎样才能获取CListCtrl的列属性中的pszText内容!??急,解决马上结贴!~

解决方案 »

  1.   

    CListCtrl::GetItemText
    This method retrieves the text of a list view item or subitem. If nSubItem is zero, this method retrieves the item label; if nSubItem is nonzero, it retrieves the text of the subitem. For more information about the subitem argument, see the discussion of the LVITEM structure in CListCtrl::GetItem.CString GetItemText(
    int nItem,
    int nSubItem )
    const;int GetItemText(
    int nItem,
    int nSubItem,
    LPTSTR lpszText,
    int nLen )
    const; 
    Parameters
    nItem 
    Specifies the index of the item whose text is to be retrieved. 
    nSubItem 
    Specifies the subitem whose text is to be retrieved. 
    lpszText 
    Specifies a pointer to a string that is to receive the item text. 
    nLen 
    Specifies the length of the buffer pointed to by lpszText. 
    Return Value
    The version returning int returns the length of the retrieved string.The version returning a CString returns the item text.Requirements 
      Windows CE versions: 1.0 and later  
      Header file: Declared in Afxcmn.h
      Platform: H/PC Pro, Palm-size PC, Pocket PCSee Also
    CListCtrl::GetItem
      

  2.   

    Sorry,我没有表达清楚,是Column的pszText属性不是Item的
      

  3.   

    CListCtrl *pList = (CListCtrl*)GetDlgItem(IDC_LIST1);
    int nColumnCount = pList->GetHeaderCtrl()->GetItemCount();
    CString strUpdateSql;
    LVCOLUMN col;
    LPTSTR psztext = NULL;
    col.mask = LVCF_TEXT; for(int i = 0; i < nColumnCount; i++)
    {
    if(pList->GetColumn(0, &col))
    {
    CString colChName = col.pszText;
    int nwidth = pList->GetColumnWidth(i);
    strUpdateSql.Format(_T("Column Width is: %d ; \n Column Text is: '%s'" ), nwidth, colChName);
    }
              }
    if条件语句中的内容怎么不执行〉??
      

  4.   

    因为你没有初始化LVCOLUMN col;
    看看MSDN就明白了
      

  5.   

    再加上下面的语句就可以了
    char* buf = new char[10];
    col.mask = LVCF_TEXT;
    col.pszText = buf;
    col.cchTextMax = sizeof(buf);
      

  6.   

    下面的代码是挖出来的,可以用拉:
    LVCOLUMN col;
    char buffer[128];
    col.mask = LVCF_TEXT;
    col.cchTextMax = 128;
    col.pszText = buffer;
    GetListCtrl().GetColumn(iCol,&col);