how can I sort by alphabetically the items of a wxListCtrl simply?

可紊 提交于 2020-01-06 08:47:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!