我怎么能按字母顺序排序wxListCtrl的项目? [英] how can I sort by alphabetically the items of a wxListCtrl simply?

查看:172
本文介绍了我怎么能按字母顺序排序wxListCtrl的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以给我一个简短的解释,如何按字母顺序排序wxListCtrl的项目?我认为我找到了一种方法,但似乎太复杂了。

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.

提前感谢!

推荐答案

您可以设置注释中提到的样式,也可以使用 SortItems 方法

You can set the style as mentioned in the comment and you also can use SortItems method

像这样:

listCtrl->SortItems(CompareFunction, 0);

比较函数应该类似于 strcmp

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

这篇关于我怎么能按字母顺序排序wxListCtrl的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆