SkillAgentSearch skills...

TreeViewFolderBrowser

Supports Explorer, SingleChecked and RecursiveChecked mode (checkboxes). Lets you specify the displayed drive types etc..

Install / Use

/learn @ChrisRichner/TreeViewFolderBrowser
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

chrisrichner MyGet Build Status

TreeViewFolderBrowser

Supports Explorer, SingleChecked and RecursiveChecked mode (checkboxes). Lets you specify the displayed drive types etc..

Demo Application

Based on popular demand in the discussion area I've decided to put the latest code out in the wild. The software is provided "as is". Bear in mind that this is an early 3.0.0 Version which never made it's way to codeproject.com.

Introduction

This tree view control gives you the ability to control which drive types are displayed to let the user choose directories. A possible scenario is to show only local drives, because your Application scan the selected directories and fill a database with the generated meta data, and it makes no sense to allow directories from removable drives.

Design

Introduction

This release has a new design which is based on a tree view which aggregates a tree view data provider interface (Strategy pattern). The goal of the new design is to provide an easy way to extend or add data providers without changing a single line of tree view code. Basically the tree view interface will not change so far, but the data providers will change their behavior and features.

TreeViewFolderBrowser class defines the following core requirements

  • DriveTypes
  • RootFolder
  • CheckboxBehaviorMode

and is responsible to manage the checkboxes and the internal selected directories list.

ITreeViewFolderBrowserDataProvider is used by aTreeViewFolderBrowser instance and is responsible to

  • retrieve the computer drives and directories
  • Imagelist which is used to assign images to the nodes created by this instance
  • ContextMenu

and can provide custom features and behavior to extend theTreeViewFolderBrowser class.

TreeViewFolderBrowser

You can specify the drive types through a public instance property on the control. The enumeration can be treated as a bit field, that is, a set of flags.

<table id="table2" cellspacing="0" class="dtTABLE"><tbody><tr valign="top"><th width="50%">Member Name</th><th width="50%">Description</th></tr><tr valign="top"><td width="50%">**NoRootDirectory**</td><td width="50%">NoRootDirectory</td></tr><tr valign="top"><td width="50%">**RemovableDisk**</td><td width="50%">Drive has removable media. This includes all floppy drives and many other varieties of storage devices.</td></tr><tr valign="top"><td width="50%">**LocalDisk**</td><td width="50%">Drive has fixed (nonremovable) media. This includes all hard drives, including hard drives that are removable.</td></tr><tr valign="top"><td width="50%">**NetworkDrive**</td><td width="50%">Network drives. This includes drives shared anywhere on a network.</td></tr><tr valign="top"><td width="50%">**CompactDisc**</td><td width="50%">Drive is a CD-ROM. No distinction is made between read-only and read/write CD-ROM drives.</td></tr><tr valign="top"><td width="50%">**RAMDisk**</td><td width="50%">Drive is a block of Random Access Memory (RAM) on the local computer that behaves like a disk drive.</td></tr></tbody></table>

The different CheckboxBehaviorMode indicates whether check boxes are displayed next to the tree nodes in the tree view control and how the tree view handle related events. The main difference between SingleChecked and RecursiveChecked behavior, lies in the fact that the user can't unselect sub folders of a checked folder in RecursiveChecked mode.

<table id="table3" cellspacing="0" class="dtTABLE"><tbody><tr valign="top"><th style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">Member Name</th><th style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">Description</th></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**None**</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**No check boxes**are displayed next to the tree nodes in the tree view control.</td></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**SingleChecked**</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**Check boxes**are displayed next to the tree nodes in the tree view control. The user can check directories.</td></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**RecursiveChecked**</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**Check boxes** are displayed next to the tree nodes in the tree view control. The user can check directories, the**subdirectories are checked recursive**.</td></tr></tbody></table>

The root folder property let you specify where the browsing starts from. Root folder values are defined bySystem.Environment.SpecialFolder.

<table id="table4" cellspacing="0" class="dtTABLE"><tbody><tr valign="top"><th style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">Member Name</th><th style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">Description</th></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**Desktop**</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">The tree view control shows a virtual desktop root node. Personal node points to the user my files folder. The MyComputer node shows the**specified drive types**.</td></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">**MyComputer**</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">The tree view control shows the**specified drive types** on the root.</td></tr><tr valign="top"><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">All other values from`System.Environment.SpecialFolder`</td><td style="BORDER-RIGHT: #999999 0px solid; PADDING-RIGHT: 6px; BORDER-TOP: #999999 0px solid; PADDING-LEFT: 6px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #999999 1px solid; TEXT-ALIGN: left" width="50%">The tree view control shows the specified root folder, the**drive types are ignored**.</td></tr></tbody></table>

The combination ofDriveType,CheckboxBehaviorModes andSpecialFolder enumeration values gives you the ability to control how the tree view display it's content and behaves when you select a directory.

DataProvider

Data providers are the workers behind theTreeViewFolderBrowser which controls them. By implementing theITreeViewFolderBrowserDataProvider interface, you will have full control over the core processes like retrieving data, assign images to the nodes and provide customContextMenu items for each node. But you don't have to care about checkboxes, load on demand, find node at position if the user request theContextMenu, you will be hooked if it's time to take

Related Skills

View on GitHub
GitHub Stars25
CategoryProduct
Updated6mo ago
Forks9

Languages

C#

Security Score

82/100

Audited on Sep 24, 2025

No findings