问题
can anyone give me a short explanation about how to sort by alphabetically the items of a wxListCtrl? I think that I found a way but it seems too complicated.
Thank You in advance!
回答1:
You can set the style as mentioned in the comment and you also can use SortItems
method
like this:
listCtrl->SortItems(CompareFunction, 0);
When compare function should act similar to strcmp
:
int wxCALLBACK CompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr WXUNUSED(sortData))
{
if(item1<item2) return -1;
if(item1>item2) return 1;
if(item1==item2) return 0;
}
来源:https://stackoverflow.com/questions/26476869/how-can-i-sort-by-alphabetically-the-items-of-a-wxlistctrl-simply