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

x
?
Solved

How to sort the ListView?

Posted on 2002-04-27
9
Medium Priority
?
195 Views
Last Modified: 2010-05-02
I'm using a list view control for a FTP client program. I add all the files to the ListView in Report Style and add pictureA if its a file or PictureB if its a folder. How can I sort the list but first the folders and then the Files just like in Windows Explorer?

thanks
0
Comment
Question by:matrix717
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6973767
I think populate the list, first with folders and then with files. You don't need to run enumfiles twice, you could use two arrays and populate each one, one with files and other with folders mane in the same "lap".
Hope it helps.
I did try several ideas to order listviews and none was enought.
0
 

Author Comment

by:matrix717
ID: 6973784
how can I order an array alphabeticaly?
0
 
LVL 46

Accepted Solution

by:
aikimark earned 280 total points
ID: 6974343
You might be able to accomplish what you want by creating an "invisible" column in the listview, containing a combination of type-descriptor and name characters, and invoking the sort method on this column.

Example:
d_dirname3
d_dirname1
f_filename4
d_dirname2
f_filename1
f_filename3
f_filename2

In this example, the name of the object (dir/file) is prepending with an associated object type descriptor ("d_" and "f_").  Since "d" is less than "f" in the collating sequence, the result of the sort method will result in your desired ordering.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:raizon
ID: 6974550
aikimark,

wouldn't that give you a listing order of

d_dirname1
d_dirname2
d_dirname3
f_filename1
f_filename2
f_filename3
f_filename4

I think you are on the right track however.
I would add a number to the front of your descriptor which will be the order in which they are to be listed.

1d_dirname1
2d_dirname2
3f_filename1
4d_dirname3
5f_filename1
6f_filename2
7f_filename3
8d_dirname4


Just a thought
0
 
LVL 15

Expert Comment

by:ameba
ID: 6974716
Add space (" ") to folder names.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 6974900
string data is sorted in left-to-right sequence.

1. all the "d_" items will appear before any "f_" item.
2. the strings (names) within each "group" will appear in their correct alphabetic sequence.

"try it...you'll like it" :-)
(quote from an old Alka Seltzer commercial)
0
 
LVL 46

Expert Comment

by:aikimark
ID: 6974908
Example of what you should see:

d_alongdirectoryname
d_bnatural
d_csharp
f_notadirectory
f_plentyoftheseonyourharddrive
f_seethepatternyet
f_thisisthelastthingtosortinyourlistview
0
 
LVL 5

Expert Comment

by:raizon
ID: 6974981
I think I missunderstood what he was wanting.

I thought he was wanting a TreeView but without using the TreeView control.
0
 

Author Comment

by:matrix717
ID: 6976500
I repeat, what I want is to sort the files and folders just as Windows Explorer does...

Folder AAA
Folder AAB
Folder CCA
File   AA
File   AB

I want to press the header and that the files an folders of that column get sort on that way...


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

704 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