WM5 中的ListView控件怎么排序? 望指点
WM5 中的ListView控件怎么排序? 望指点
算法也行 直接告诉通过电击列表头排序更好 :)
[解决办法]
如果是.Net,MSDN上面说的非常清楚:
http://msdn2.microsoft.com/zh-cn/library/ms229643(VS.80).aspx
[解决办法]
先 GetListCtrl 得到 ListCtrl,ListCtrl 有函数 SortItems:
// Sort the item in reverse alphabetical order.
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// lParamSort contains a pointer to the list view control.
// The lParam of an item is just its index.
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
CString strItem1 = pListCtrl->GetItemText(lParam1, 0);
CString strItem2 = pListCtrl->GetItemText(lParam2, 0);
return strcmp(strItem2, strItem1);
}
void snip_CListCtrl_SortItems()
{
// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;
// Sort the list view items using my callback procedure.
pmyListCtrl->SortItems(MyCompareProc, (LPARAM) pmyListCtrl);
}