CListBox的AddString 排序问题

在用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 清单进行排序

你可能感兴趣的:(list,String,function)