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

x
?
Solved

Turn off sorting in CListCtrl

Posted on 1998-06-24
2
Medium Priority
?
1,149 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 800 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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

773 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