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
Sorry,我没有表达清楚,是Column的pszText属性不是Item的
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条件语句中的内容怎么不执行〉??
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
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条件语句中的内容怎么不执行〉??
看看MSDN就明白了
char* buf = new char[10];
col.mask = LVCF_TEXT;
col.pszText = buf;
col.cchTextMax = sizeof(buf);
LVCOLUMN col;
char buffer[128];
col.mask = LVCF_TEXT;
col.cchTextMax = 128;
col.pszText = buffer;
GetListCtrl().GetColumn(iCol,&col);