Solved

Turn off sorting in CListCtrl

Posted on 1998-06-24
2
992 Views
Last Modified: 2013-11-20
I've got a CListCtrl in a dialog that has a list of files as it's items, and some other data (for each file) as subitems. I'd like to have the thing automatically sort the list (by setting the "sort" option in the resource editor), rather than having to manually sort the list. The problem comes when I want to add a new file (and associated subitems) to the list. My idea was to use InsertItem to add the filename at the end of the list, and then SetItem to add the associated subitems. However, when I call InsertItem(), the control immediately resorts the list, so the item I just added is no longer where I put it; consequently, I don't know which item # to use in the call to SetItem().

Finally, the question: is there a way to temporarily disable the control's sorting until I finish adding the subitems?
0
Comment
Question by:jadcock
2 Comments
 
LVL 2

Accepted Solution

by:
Belgarat earned 200 total points
ID: 1318395
CListCtrl::SetItem() returns an integer value - the ACTUAL index of newly inserted item. The returned index corresponds to the item's position AFTER the item is placed to the appropriate position.
If you really want to disable the sorting, remove LVS_SORTASCENDING/LVS_SORTDESCENDING from the list control's window style.
0
 

Author Comment

by:jadcock
ID: 1318396
Aaargh! The answer's so obvious, it's gotta be right! Thanks.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 38
notReplace  challenge 53 102
fizzArray  challenge 1 47
changeXy challenge 13 57
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now