CListBox的AddString 排序问题

来源:互联网 发布:什么是算法设计 编辑:程序博客网 时间:2024/05/17 22:27

在用CListBox添加元素时发现显示的顺序与预期的不同

原因:

CListBox::AddString  

Remarks

Call this member function to add a string to a list box. If the list box was not created with the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted. If the list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the framework sorts the list by one or more calls to the CompareItem member function.


CListBox默认对各项进行排序,在属性中把sort改为false就解决问题了,或者用InsertString(),而不是 AddString()。InsertString() 不会导致 LBS_SORT 清单进行排序

原创粉丝点击