之前一直在网上搜索有关得到CListContrl的headers的text属性,但是多次搜索结果都是出错
网上的一段代码是这样的,但是我用vs2010测试结果抛出异常:
LVCOLUMN lvcol;
char str[256];
int nColNum;
CString strColumnName[4];//假如有4列
nColNum = 0;
lvcol.mask = LVCF_TEXT;
lvcol.pszText = str;
lvcol.cchTextMax = 256;
while(m_list.GetColumn(nColNum, &lvcol))
{
strColumnName[nColNum] = lvcol.pszText;
nColNum++;
}
测试通过的样例是这样:
int nColNum = 0;
TCHAR name[40];
LVCOLUMN col;
// Get column name
col.mask=LVCF_TEXT;
col.pszText=name;
col.cchTextMax=40;
Lists.GetColumn(0, &col);
while(Lists.GetColumn(nColNum, &col)){
CString tValue = col.pszText;
headers.Add(tValue);
nColNum++;
}