各位大侠,我在应用列表控件时,发现CListCtr::SetItem(LVITEM*)函数问题操作失败,下面是代码,请各位帮忙看一下。
LVITEM lvi={0};
CString strItem;
for(int i=0;i<m_nDyeStep.GetCount();i++)
{
// Use the LV_ITEM structure to insert the items
// Insert the first item
vi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
strItem.Format("第%d步:",i+1);
lvi.iItem = m_nStepNum;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
lvi.iImage =-1; // There are 13 images in the image list
lvi.lParam=100*i;
m_CDetail.InsertItem(&lvi);
// Set subitem 1
strItem=_T("");
lvi.iSubItem =1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
lvi.iImage = -1;
m_CDetail.SetItem(&lvi);//问题就出在这个地方!!!!!!!
}
------解决方案--------------------------------------------------------
m_CDetail.SetItem(&lvi);之前加一行lvi.mask = LVIF_IMAGE | LVIF_TEXT;试试。