Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Turn off sorting in CListCtrl

Posted on 1998-06-24
2
Medium Priority
?
1,113 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

722 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