custom sorting a tree view (making folders show on top)

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

How would you go about doing this

I have a tree view which where anything is a parent it is a folder (folder
icon, and the tag for the object is a string that says "FOLDER:{name of
folder here}") then each folder has items in it and possibly more folders.
The root node also has items on it that are not folders... but default
sorting sorts by name, so folders do not show up on top. pretty much
anything that has children are to show on top (because they are a folder).
How would I get a tree view to sort like this? Thanks!
 
I don't think there is support for custom sorting out of the box for the
TreeView class. You ill have to resort to Win32 API using PInvoke. Using the
API, you can custom sort a node by specifying a callback function which is
called every two nodes need to be compared. Use the TVM_SORTCHILDRENCB
Message to sort the children of a particular node.

-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
 
If the standard TreeView doesn't offer this support,
take a look at our TList control.
( www.Bennet-Tec.com )
The ItemSortingStyle property allows you to specify
whether to place all folders belonging to a node above or
below other children when sorting the children.

* * Please include a copy of this message with your reply

-----

Jeff Bennett
(e-mail address removed)

* Bennet-Tec Information Systems, Inc
* 50 Jericho Tpk, Jericho, NY 11753
* Phone 516 997 5596, Fax - 5597
* RELIABLE Components Make You Look Sharp!
* TList/Pro * ALLText HT/Pro * MetaDraw *
* Custom Software Development Services Too.
* WWW.Bennet-Tec.Com

=================== ===================
 
If you are willing to consider a commercial control take a look at
Infralution's Virtual Tree control. It has a sample File Browser
application that does exactly what you want. You can download a fully
functional evaluation version at:

www.infralution.com/virtualtree.html

Regards
Grant Frisken
Infralution
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top