user3530026
user3530026

Reputation:

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

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!

Upvotes: 0

Views: 1301

Answers (1)

SHR
SHR

Reputation: 8313

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

Upvotes: 1

Related Questions