Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1218
  • Last Modified:

CListBox disable/enable sorting

Hi can anyone show me the code for disable/enable the sorting function for a CListBox at anytime? Also, is it possible to make it sort in ascending sort or descending order?

i've tried these but it's not working.

m_ctlList.ModifyStyleEx(NULL,LBS_SORT); //to enable sorting
 
0
rw8
Asked:
rw8
1 Solution
 
skibud2Commented:
from this link,
    http://www.codeproject.com/combobox/listbox_tut.asp

you can find this:

It is not possible to change these styles at runtime even though ModifyStyle() may give the impression it does. If you want turn the Sort style on and off for example it is best to construct the List box by calling new and Create then deleting it and creating a new one when the style is to be changed. Alternatively you can have 2 List box superimposed and hide the one with the incorrect style.

In the Demo the List box headed 'Toggle List Style' which changes the LBN_SORT style. The code deletes the old List box and creates a new one each time the Toggle button is clicked.
0
 
rw8Author Commented:
Thanks it's excelletn!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now