By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Brian Henry" <no****@nospam.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
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!

Nov 21 '05 #2

P: n/a
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
Je**@Bennet-Tec.Com

* 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

=================== ===================

Nov 21 '05 #3

P: n/a
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

Brian Henry wrote:
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!


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.