Solved

Turn off sorting in CListCtrl

Posted on 1998-06-24
2
1,030 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to include alternate header placement and naming 5 75
viewing source code from eclipse 13 110
tripleUp challenge 7 86
Excel file not created as expected 7 79
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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