GetItem返回的是第一个Item,继续遍历就要GetNextItem(), FindItem的例子 // Pointer to the list view control. CListCtrl* pmyListCtrl; // The string to match. LPCTSTR lpszmyString;LVFINDINFO info; int nIndex;info.flags = LVFI_PARTIAL|LVFI_STRING; info.psz = lpszmyString;// Delete all of the items that begin with the string lpszmyString. while ((nIndex=pmyListCtrl->FindItem(&info)) != -1) { pmyListCtrl->DeleteItem(nIndex); }
FindItem的例子
// Pointer to the list view control.
CListCtrl* pmyListCtrl;
// The string to match.
LPCTSTR lpszmyString;LVFINDINFO info;
int nIndex;info.flags = LVFI_PARTIAL|LVFI_STRING;
info.psz = lpszmyString;// Delete all of the items that begin with the string lpszmyString.
while ((nIndex=pmyListCtrl->FindItem(&info)) != -1)
{
pmyListCtrl->DeleteItem(nIndex);
}
难道连续用GETNEXTITEM函数N次?
如果要得出一个当前选中的item,只能通过getcheck函数的返回值,一条一条测试吗? 顺便问一下,呵呵
m_list.GetNextItem(-1, LVIS_SELECTED);
while ((nItem = m_list.GetNextItem(nItem, LVIS_SELECTED)) != -1)
{
// nItem 为选中的项目索引号
}
我主要想问的是怎么通过记录的索引号得到这条记录的内容,就是LVITEM这么一个结构体。
怎么用GetItem获取第N条记录啊?
我看GetItem的声明是这样的啊:BOOL CListCtrl::GetItem( LVITEM* pItem ) const;
没有给我传N这个值的参数啊。
TCHAR szText[256];
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.iItem = 21; // N
lvItem.pszText = szText;
lvItem.cchTextMax = sizeof(szText);m_list.GetItem(&lvItem);