how can I sort by alphabetically the items of a wx

2019-09-11 02:30发布

问题:

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;
}


标签: c++ wxwidgets