Question

Pseudo Code:

CListBox listBox;
CString[10] str; //consider it is initialised with valid string
for(int i=0; i<10 ; i++)
     listBox.AddString(str[i]);

Whenever I add an entry/string to a CListBox object using the function AddString(), the MFC CListBox sorts the entries automatically as each string is added.

How do I explicitly tell MFC to keep the items in the same order they are added (without sorting).

PS: I do NOT want to use the function InsertString() or so.

Thanks!

Was it helpful?

Solution

In Propertiestab there is a Sort property. Set it's value to False.

Edit:
As @The Forest And The Trees already mentioned, you could achieve same result from code:
listBox.ModifyStyle(LBS_SORT);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top