Click here to Skip to main content
Click here to Skip to main content

FolderTreeView Control

By , 25 Oct 2002
 

Sample Image

Introduction

This is an all-new version of the FolderTreeView control I posted here at CodeProject some weeks ago. The control now starts in the Desktop namespace, and a new drilling method has been added so the startup folder can be specified. Please note that this control is not intended to have all of the functionality of the actual Windows Explorer TreeView - it is a light-weight control designed for use in projects where you want to supply a treeview for folder navigation, without supporting windows shell extensions. If you are looking for a control that supports shell extensions you should be looking at the excellent ËxplorerTreeControl submitted by Carlos H Perez here at the CodeProject website.

How it works

After calling the InitFolderTreeView() method, a dummy Desktop not is created as the root node, and then the shell's Desktop namespace is iterated to populate the first level nodes. The child nodes are then iterated, checking only for the presence of sub-child nodes. If sub-child nodes are found, a dummy node is inserted so that the [+] will be displayed for folders that can be expanded. When the BeforeExpand event fires, the folder being expanded is checked for a dummy node. If a dummy is present, it is removed and the node's children are re-populated. If the node's children have already been populated no further action occurs.

Usage

The FolderTreeView control is based on 3 classes:

  • FolderTreeView - The FolderTreeView implementation
  • ShellOperations - Supporting Shell Operations
  • ExtractIcons - Shell Icon Extractor
The control naturally derives from the System.Windows.Forms.TreeView, exposing 1 new property, GetSelectedNodePath() which returns the currently selected node's full path. There are 2 new methods: InitFolderTreeView() must be called to populate the TreeView - normally you would call this in your Form's OnLoad event. The 2nd method is DrillToFolder(string folderPath) - this will recurse through the tree looking for the specified folder path, returning a boolean to indicate if the search was sucessful or not.

The method used to retreive the icon for the Desktop root node works fine, but is perhaps not the best way to go about it. This control has NOT been tested in Win9x, NT or 2000 - feedback on these OS's would be much appreciated. Of course if you improve this control I would appreciate the update, and if you have any feedback to offer, please post it below.

Updates

Version 1.11:

  • Updated the GetDesktopIcon() method so it returns the shell's small desktop icon rather than the large version
  • Added code so that the Desktop node would return the full desktop folder path
I have now tested the code on Windows Me without problem - feeback on how it works with other OS's would be appreciated!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Furty
Web Developer
Thailand Thailand
Member
Furty will code for food.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralNot able to see Entire Network in My Network Placesmemberremane24 May '07 - 2:34 
GeneralCompiling on Vista, executing on XP - errormembersplattne215 Mar '07 - 3:55 
QuestionRe: Compiling on Vista, executing on XP - errormemberDynamite Jones27 Jul '07 - 5:37 
AnswerWhy are you Developing on Vista!?memberredfish3411 Oct '07 - 14:05 
You folks are nutty in the head for developing on Vista.

GeneralRe: Why are you Developing on Vista!?memberdatacore29 Oct '08 - 21:22 
QuestionHow to remove the A: drive(diskette) from the tree?memberrytek909 Feb '07 - 4:47 
QuestionConnection to Live ID?memberSeikilos11 Jan '07 - 9:57 
AnswerRe: Connection to Live ID?memberSeikilos15 Jan '07 - 7:44 
QuestionHourglass Cursor in ExpandBranchmembergoondoo2717 Nov '06 - 12:20 
AnswerRe: Hourglass Cursor in ExpandBranchmembergoondoo2720 Nov '06 - 6:08 
QuestionHow To Remove Network Neighbourhood, Internet Explorer and Recyle Bin ?memberscorpion_pgm8230 Aug '06 - 2:22 
GeneralList All Computers in the networkmemberShailesh Halankar28 May '06 - 23:35 
GeneralRe: List All Computers in the networkmemberdatacore22 Jun '06 - 20:58 
QuestionProblem with icons colorsmemberGalanty22 Mar '06 - 23:43 
AnswerRe: Problem with icons colorsmembersir_mad23 Mar '06 - 0:15 
GeneralRe: Problem with icons colorsmemberGalanty24 Mar '06 - 8:21 
AnswerRe: Problem with icons colorsmembernguyen_freddie17 Jan '10 - 17:55 
GeneralDrillToFolder and unc-pathmembertabor252 Mar '06 - 5:29 
GeneralPay attention to shell extensionsmemberLiviu7 Feb '06 - 4:10 
QuestionRe: Pay attention to shell extensionsmembersir_mad22 Mar '06 - 4:53 
QuestionWhat about the hidden directory ?memberbilb0t1 Feb '06 - 3:22 
GeneralExcellentmember-Dy24 Jan '06 - 10:25 
GeneralPerformance and network neighbourhoodmemberrubberring8 Nov '05 - 10:32 
GeneralRe: Performance and network neighbourhoodmemberdario7711 Jan '06 - 7:06 
QuestionControl in Designer with DLL Compilationmemberakiriwas8 Oct '05 - 17:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 26 Oct 2002
Article Copyright 2002 by Furty
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid