C# Tips and Tricks >  Windows Explorer Tree control


Sample Image - ExplorerTree.jpg

Introduction

Idea: Functionality of windows explorer wrapped up as a control. User can browse through all the folders in the computer including network folders and select the path.

The Long story, while working on a photo editing software i frequently needed to test different images from different folders. i have to call an open dialog then browse for the folder and then select the file. 4 clicks well not too much but if you have to test 10 images in the same folder same process have to be repeated for all of them, more if you have 10 images in different folders well 10 X 4 clicks, i call it Multiple Mouse Clicks For Single Operation (MMCFSO). Explains why the whole software world relates reducing MMCFSO with the ease of use.

MMCFSO is not just needed for a imaging application. Where ever you have to select multiple files from multiple destinations you need this. So i think an effort to create a windows explorer user control is worth it. Here is the result.

To hold your interest, here is how the ExplorerTree control looks like.

  

A UserControl is an object which can display and accept information from a user. It usually fulfills a specific functions of input or output. What is our ExplorerTree control going to do ?

1. Display a treeview of all the folders like Windows Explorer 
2. It will take user input as mouse click and expand the folder
3. Output will be the path of the current selection

The target was to create a user friendly control which simulates windows explorer with the following 

  • Rich functionality: It should be rich in functionality and have all the capabilities of a windows explorer 
    • Browse all possible folders my documents, desktop, network neighbourhood etc 
    • Go, up, back, next features like Windows explorer  
    • Enable /disable the folders he wants to see aka My Documents/ My Network/My Favorites etc
  • Nice user interface: It should look professional and neat
  • Reusability: The feature should work as a control user can drop it in any form and have a readymade functionality of a windows explorer.
  • Extensibility: User should be able to add shortcut to frequently used folders

Acknowledgement

Thanks to Rob Manderson for his article on porting the NetResource class in C sharp here http://www.codeproject.com/csharp/csenumnetworkresources.asp and also all those authors who have contributed for code project whose ideas knowingly or unknowingly, directly or indirectly have influenced me to write this article.

Article History

  • June 25, 2006: First published.
  • July 20, 2006: Bug fixed as mentioned by Lyle M, thanks
  • August 11, 2006: Bug fixes mentioned by Doncp and pcxp, thanks
  • August 11, 2006: Features added for customizable interface, without toolbar amd addressbar
  • Dec 14, 2006: Fixed and updated with all the requested features (see comments below) thanks to psxp, evan stein and otopia and BigfootIndy2k6 for there comments  
Comments / Suggestions


screen  Add a Comment 
Subject  User  Date 
Last Visit: 1:47:54 PM, Friday, November 21, 2008


You can also reach me at: here

Rate This Page