|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis 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. DesignIntroductionThis 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.
and is responsible to manage the checkboxes and the internal selected directories list. ITreeViewFolderBrowserDataProvider is used by a TreeViewFolderBrowser instance and is responsible to
and can provide custom features and behavior to extend the TreeViewFolderBrowserYou 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.
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.
The root folder property let you specify where the browsing starts from. Root folder values are defined by
The combination of DataProviderData providers are the workers behind the To provide clean access to the handled Please take a look at the two delivered standard implementations which can be found in the Key featuresTreeViewFolderBrowser
TreeViewFolderBrowserDataProvider
TreeViewFolderBrowserDataProviderShell32Inherit from TreeViewFolderBrowserDataProvider
Using the codeBefore you begin make sure your project has a valid reference to the Raccoom.TreeViewFolderBrowser.dll. Go to the Toolbox window, right-click and select Customize Toolbox from the context menu. In the Customize Toolbox dialog go to the .NET Framework Components tab and select the Raccoom.TreeViewFolderBrowser.dll assembly that you just compiled. Now drop the TreeViewFolderBrowser control to your form. This example assumes that you have created an instance of a TreeViewFolderBrowser control on a Form. Fill data // set standard data provider
this.myTreeView.DataSource =
new Raccoom.Windows.Forms.TreeViewFolderBrowserDataProvider();
// set drive types
this.myTreeView.DriveTypes
= DriveTypes.LocalDisk | DriveTypes.NetworkDrive |
DriveTypes.RemovableDisk |
DriveTypes.CompactDisc;
// set checkbox behavior mode
this.myTreeView.CheckboxBehaviorMode= CheckboxBehaviorMode.SingleChecked;
// fill root level
this.myTreeView.Populate();Event Handlingprivate void treeView_SelectedDirectoriesChanged(
object sender, Raccoom.Windows.Forms.SelectedDirectoriesChangedEventArgse)
{
// determine the path which is currently added (checked)
// or removed (unchecked)
this.statusBar1.Text = e.Path + " is now " + e.CheckState.ToString();
// display all selected path's in a listbox
this.listBox1.Items.Clear();
foreach(string s in myTreeView.SelectedDirectories)
{
this.listBox1.Items.Add(s);
}
}
ConclusionsThis control display drive types and folders, so far so good. Removable disk's can change their medium and folders can change (new folder, delete folder) during run time, the control does not care about that. Links
History
Have phun...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||