Click or drag to resize

ShellTreeView Class

A ShellTreeView displays the shell namespace in a tree. When the user right clicks on a folder, it will automatically show the context menu. Use the SelectedPath property to get the currently selected path, use the SpecialFolder property to check if a special folder like the Control Panel is currently selected. You can configure the root nodes using the MultipleRoots property. A single root can be configured using the RootedAt or RootedAtFileSystemFolder properties. Set the ShellControlConnector to synchronize the ShellTree with other components, like a ShellListView. The AddTreeNode event can be used to customize single nodes in the Tree, including the icons that are displayed.
Inheritance Hierarchy

Namespace:  Jam.Shell
Assembly:  ShellBrowser (in ShellBrowser.dll) Version: 7.0
public class ShellTreeView : TreeView, 
	IShellControl, IShellControlConnectorTarget, ISupportInitialize, ISupportInitializeNotification, IComparer, 

The ShellTreeView type exposes the following members.

Public methodShellTreeView
Initializes a new instance of the ShellTreeView class.
Public propertyAllowDrag
Use this property to turn on or off drag support with the Windows Explorer.
Public propertyAllowDrop
Use this property to turn on or off drag and drop support with the Windows Explorer.
(Overrides ControlAllowDrop.)
Public propertyAutoExpandDelay
The delay in milliseconds after that a folder is expanded automatically during a drag and drop operation. A value of 0 disables the auto expand feature.
Public propertyAutomaticRefresh
Enables the automatic refreshes of the control, e.g. when a file is added or deleted in the current directory.
Public propertyAutoScrollDelay
The delay in milliseconds after that the control scrolls automatically during a drag and drop operation. A value of 0 disables the auto scroll feature.
Public propertyBackColor
A System.Drawing.Color that represents the background color of the control. The default is the value of the System.Windows.Forms.Control.DefaultBackColor property.
(Overrides TreeViewBackColor.)
Public propertyChangeDelay
Specifies the delay between when a node is selected and when the handling of this change is processed.
Public propertyCheckBoxes
Use this property to turn on or off the checkboxes for file and folder selection. The checkboxes will only work, if a ShellControlConnector instance has been assigned to the ShellControlConnector property of this component. It will automatically synchronize the selection state of the items in multiple shell controls linked together with this ShellControlConnector.
Public propertyCheckBoxMode
Use this property to display checkboxes for the control.
Public propertyCompactRoots
Reduces the space between the root nodes of the Tree.
Public propertyContextMenuStrip
The ContextMenuStrip is converted to an ordinary ContextMenu. This makes it possible to merge your ContextMenuStrip with the Default ShellContextMenu provided by the system. The "Opening" and "Closing" events of the ContextMenuStrip will be raised if the ContextMenu "Popup"/"Collapse" event occurs. For menu items only the "Click" event is available. All other events are not available. All ToolStripMenuItems are converted, and ToolStripSeparators are recognized. The ShortCut Keys defined in a ToolStripMenuItem are not converted. If you would like to have the ShortCut-Keys, leave this Property null, instead set the ContextMenu property to your menu explicitly.
Public propertyCopyMode
Copy mode allows you to control the behaviour when files or folders get dropped.
Public propertyCode exampleCustomImages
Contains an ImageList holding custom icons.
Public propertyDrawMode
The value of the DrawMode property must always be TreeViewDrawMode.OwnerDrawAll. This is why the Property is reimplemented here. A different setting is ignored, and a debug message is shown.
Public propertyCode exampleEmptyIconIndex
Gets the zero-based index of the empty icon.
Public propertyFileNameFormat
Specifies, whether filename are presented with file extensions or not. By default, this depends on the respective setting in Windows Explorer.
Public propertyFileSystemOnly
If FileSystemOnly is set to True, objects and virtual folders which do not have a file system path, will not be displayed. Exceptions are 'My Computer', 'Libraries' and 'Network'
Public propertyFilter
You can use a single pattern, e.g. '*.doc' or concatenate several patterns using semicolons to separate them, e.g. '*.exe;*.com'.
Public propertyFont
The font used to display text in the control.
(Overrides ControlFont.)
Public propertyHideSelection
Gets or sets a value indicating whether the selected tree node remains highlighted even when the tree view has lost the focus.
Public propertyImageIndex
Not supported.
Public propertyImageList
Gets or sets a list of images.
Protected propertyIsEditing
Gets a value indicating whether the SelectedNode is in editing state.
Public propertyIsInitialized
Gets a value indicating whether the component is initialized.
Public propertyIsInitializing
The value this property is true between the calls BeginIniti() and EndInit() of the ISupportInitialize interface.
Public propertyItemHeight
Gets or sets the height of each tree node in the tree view control.
Public propertyLabelEdit
Gets or sets a value indicating whether the label text of the tree nodes can be edited.
Public propertyLargeIcons
Set or get the ImageSize. True for LargeIcons, false for SmallIcons.
Public propertyCode exampleMultipleRoots
Configuration of the roots that are displayed in the ShellTreeView
Public propertyNodes
Returns a collection containing all child ShellTreeNodes of this ShellTreeNode.
Public propertyNoFillOnStartup
If set to true, the control will not fill automatically after it was created. The FullRefresh method must be called explicitly. Since filling shell control with the appropriate items is a costly operation, this property can be useful to prevent unnecessary refreshes of the control.
Public propertyReadOnly
If true, the folder actions changing the contents of the folder are not allowed. E.g.: Adding, removing or renaming files via context menu, DragDrop, Copy/Paste.
Public propertyRootedAt
Defines the root folder of this ShellTreeView
Public propertyRootedAtFileSystemFolder
Determines the root file system folder of a ShellTreeView.
Public propertyRootNode
Returns the first root element of the type ShellTreeNode of this shell treeview.
Public propertySelectedImageIndex
Not supported.
Public propertySelectedNode
Gets or sets the tree node that is currently selected in the ShellTreeView control.
Public propertySelectedPath
Use SelectedPath to get or set the path, which is currently selected in the ShellTreeView. If the currently selected path is not a file system folder, SelectedPath returns an empty string and you should use the SpecialFolder property to get the type of this path. If you`re looking for the path an operation was performed on (e.g. Drop), use the OperationPerformed event.
Protected propertyShellChangeNotifier
Returns the reference to the ShellChangeNotifier that is associated with this instance.
Public propertyShellContextMenu
Indicates whether the Windows ShellContextMenu should be shown or not.
Public propertyShellControlConnector
Connects this control to a ShellControlConnector component, which allows to synchronize several shell controls.
Public propertyShellDragDrop
Activates/deactivates the internal drag drop handling of the component.
Public propertyShowColorCompressed
If set, compressed files an folders will be shown in that particular Color, if null have show normally
Public propertyShowColorEncrypted
If set, encrypted files an folders will be shown in that particular color, show normally otherwise (if null).
Public propertyShowContextMenu
If set to true, the Windows Explorer context menu will be shown, if the user right-clicks.
Public propertyShowErrorMessages
If set to true, messages boxes will be shown to the user for errors that occured. If set to false, errors will be handled as well, but no message will be shown to the user.
Public propertyShowFiles
If set to true, files will be shown in the control. If set to false, files will not be visible in the control.
Public propertyShowHidden
Is set to 'true', hidden elements will be shown too.
Public propertyShowLines
Indicates whether lines are displayed between tree nodes.
Public propertyShowNetHood
If set to 'false', the Network Neighbourhood will be hidden.
Public propertyShowOverlayIcons
If set to 'false', no overlay icons will be show, which improves the performance of the control.
Public propertyShowRecycleBin
If set to true, the recycly bin will be visible. If set to false, the recycle bin will be hidden.
Public propertyShowShellContextMenuOnTop
If set to to 'true', the shell context menu will be shown on top of the provided popup menu. If set to 'false', the shell context menu will be shown below the provided popup menu. The value true is currently not supported. The menu items will be shown correctly, however their Click event cannot be triggered.
Public propertySpecialFolder
SpecialFolder allows you to check, if the currently selected folder is a special folder (e.g. the Control Panel) or to make a special folder the selected folder. Use the SelectedPath property if you want to deal with file system folders.
Public propertyUseSystemFont
Set this property to true if you want the component to utilize the default system font. It is also set to true if the UseSystemStyles property is set.
Public propertyUseSystemStyles
Use this property to turn on or off the usage of the system specific design, i.e. enable Vista visual styles of the explorer components.
Public propertyVersion
The current version of the ShellBrowser.
Public methodAddRoot(ItemIdList)
Adds a root.
Public methodAddRoot(ShellFolder)
Adds a root.
Public methodAddRoot(String)
Adds a root.
Protected methodAddShellItem
This methods adds the currently active object of the m_ShellBrowser to the TreeNode.
Public methodBeginInit
Signals the object that initialization is starting.
Protected methodCanNavigate
Called, before the ShellList displays a new folder. Calls the CanNavigate(Object, ItemIdList) implementation if assigned.
Protected methodChangeNotificationHandler
This method gets called by the ShellChangeNotifier object and informs about changes in the current folder. It sets the cursor of the ShellTreeView to the correct position if i.e. a file was renamed, a network drive was unmounted, etc.
Public methodClearRoots
Clears all roots in the ShellTreeView.
Public methodCompare
Compares two ShellTreeNode objects by their ItemIdList.
Protected methodCompleteDetails
Completes the visual details of the given item, e.g. icon, overlay image etc.
Public methodCreateDir(String, Boolean)
This method creates a new directory with the name of the string argument p_FolderName in the currently SelectedPath. If EditMode is True, the new folder will be switched to the edit mode after creation so that the user can change its name.
Public methodCreateDir(String, String, Boolean)
This method creates a new directory with the name of the string argument foldername in the given path. If EditMode is True, the new folder will be switched to the edit mode after creation so that the user can change its name.
Protected methodCreateShellTreeNode
This methods creates a new ShellTreeNode but does not yet include it in the parentNode.
Public methodDisplayContextMenu
Shows the shell context menu for the currently selected item
Protected methodDispose
Remove reference to ShellControlConnector and implicitely remove this control from the list of known controls of the ShellControlConnector
(Overrides TreeViewDispose(Boolean).)
Public methodEnableSystemStyles
Sets system specific behaviour, i.e. disables the lines in the ShellTreeView for Vista and upwards.
Public methodEndInit
Signals the object that initialization is complete.
Protected methodFillFolder
Fills in the subfolders in a node
Protected methodFindNode(ItemIdList, Boolean)
Searches for the first node, that represents the passed ItemIdList. Checks all roots in the ShellTree.
Protected methodFindNode(ItemIdList, Boolean, ShellTreeNode)
Searches for the first node, that represents the passed ItemIdList. Checks all roots in the ShellTree.
Protected methodFindNode(ShellTreeNode, ItemIdList, Boolean, ShellTreeNode)
Searches for the first node, that represents the passed ItemIdList.
Public methodFolderChanged
Change the current folder to the one given in parameter throws ArgumentNullException if the argument was null
Public methodFullRefresh
Use the FullRefresh method if you want to refresh a ShellTreeView. All expanded branches of the file system structure will be refreshed. If you just want to refresh one node and its child nodes, use the RefreshNode(ShellTreeNode, Boolean, Boolean) method.
Protected methodGotoFolderIdList(ItemIdList)
Selects the ShellTreeNode for the given ItemIdList.
Public methodGotoFolderIdList(ItemIdList, ShellTreeViewGotoFolderIdListAction)
Tries to find the ShellTreeNode for the given ItemIdList and executes the requested action on it.
Public methodGoUp
Go up one level in the tree, does nothing if the SelectedNode is null of if the SelectedNode has no Parent (is root)
Protected methodInformPathChanged
Informs the ShellControlConnector that the selected shell folder has changed.
Public methodInvokeCommandOnSelected
Invokes the Command given as a parameter on the currently selected Node, any necessary events are created
Protected methodOnAddTreeNode
Fires an event if an item is added to the tree.
Public methodOnAfterInvokeCommand
Is called after the command has been called.
Protected methodOnAfterLabelEdit
This event is triggered if the user edited a treenode and renamed it it is only active if the property base.LabelEdit was set to true
(Overrides TreeViewOnAfterLabelEdit(NodeLabelEditEventArgs).)
Protected methodOnAfterSelect
This member overrides OnAfterSelect(TreeViewEventArgs)
(Overrides TreeViewOnAfterSelect(TreeViewEventArgs).)
Protected methodOnBeforeCollapse
Raises the BeforeCollapse event.
(Overrides TreeViewOnBeforeCollapse(TreeViewCancelEventArgs).)
Protected methodOnBeforeExpand
This event is triggered before a tree node is expanded, by clicking on 'plus', in case the node has not been expanded before, it will instantly be filled with the files found in that particular path (by AddShellItem(ShellTreeNode, ShellBrowser))
(Overrides TreeViewOnBeforeExpand(TreeViewCancelEventArgs).)
Public methodOnBeforeInvokeCommand
Is called before the command is called.
Protected methodOnBeforeLabelEdit
This event is triggered if the user just starts editing a label
(Overrides TreeViewOnBeforeLabelEdit(NodeLabelEditEventArgs).)
Protected methodOnBeforeShellDrop
Calls the BeforeShellDrop event if it is assigned.
Protected methodOnCheckStateChanged
Fires an event if the CheckState of an item has changed.
Protected methodOnCreateControl (Overrides ControlOnCreateControl.)
Protected methodOnDoubleClick
Override the OnDoubleClick event to try to perform the default action for the selected object if it is a file.
(Overrides ControlOnDoubleClick(EventArgs).)
Protected methodOnDragDrop
This member overrides OnDragDrop(DragEventArgs)
(Overrides ControlOnDragDrop(DragEventArgs).)
Protected methodOnDragEnter
This member overrides OnDragEnter(DragEventArgs)
(Overrides ControlOnDragEnter(DragEventArgs).)
Protected methodOnDragLeave
This member overrides OnDragLeave(EventArgs)
(Overrides ControlOnDragLeave(EventArgs).)
Protected methodOnDragOver
This member overrides OnDragOver(DragEventArgs)
(Overrides ControlOnDragOver(DragEventArgs).)
Protected methodOnDrawNode
Loads the node and raises the draw tree node event.
(Overrides TreeViewOnDrawNode(DrawTreeNodeEventArgs).)
Public methodOnFolderUpdated
Fires the FolderUpdated event with the given argument and "this" as the sender
Protected methodOnHandleCreated
This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.
(Overrides TreeViewOnHandleCreated(EventArgs).)
Protected methodOnItemChecked
Raises the OnItemCheckedEvent.
Protected methodOnItemDrag
This member overrides OnItemDrag(ItemDragEventArgs)
(Overrides TreeViewOnItemDrag(ItemDragEventArgs).)
Protected methodOnKeyDown
Overrides the OnKeyDown event to handle key strokes for the currently selected item. Currently, if the spacebar is pressed, the checkboxes are toggled.
(Overrides TreeViewOnKeyDown(KeyEventArgs).)
Protected methodOnKeyUp
Overrides the OnKeyUp event to handle key strokes for the currently selected item e.g. the ContextMenuPopup key
(Overrides TreeViewOnKeyUp(KeyEventArgs).)
Protected methodOnMouseUp
Overrides the OnMouseUp event, to handle e.g. double clicks and right clicks on files or folders
(Overrides ControlOnMouseUp(MouseEventArgs).)
Protected methodOnOperation
Fires an event if an operation was performed on the ShellTreeView, i.e. an Item was pasted.
Public methodRefresh(RefreshLevel)
This method indicates that the control should perform a refresh of its contents.
Public methodRefresh(RefreshLevel, ItemIdList)
This method indicates that the control should perform a refresh of its contents.
Protected methodRefreshNode
Refreshes a Node, by clearing its content, and refilling the sub-tree with new, probably more current information from the file-system OnBeforeExpand(TreeViewCancelEventArgs)
Protected methodScaleControl
Scales a control's location, size, padding and margin.
(Overrides ControlScaleControl(SizeF, BoundsSpecified).)
Public methodSelectedFileChange
Change the currently selected file, if ShowFiles is true throws ArgumentNullException if the argument was null
Public methodSelectSubFolder
Selects a sub folder (if existant) of the name given as a parameter if p_FolderName is null an ArgumentNullException is thrown. if no node is currently selected nothing happens and false is returned. if no sub folder of the given name exists the method returns false as well.
Protected methodSetFont
Sets the font without adjusting other properties.
Public methodShowContextMenuForNode
Shows the shell context menu for the item given as a parameter
Public methodSmartRefresh
Use the SmartRefresh to update the contents of a ShellTreeView. In comparison to the FullRefresh method, SmartRefresh is much faster, but only removes objects which have been deleted and adds objects which have been added. It doesn't update changed file sizes or dates. Usually this method will be called automatically, when a file was added or deleted.
Protected methodWndProc
Overrides the WindProc function and filters ERASEBKGND to avoid flickering.
(Overrides TreeViewWndProc(Message).)
Public eventCode exampleAddTreeNode
This Event is triggered every time a ShellTreeNode is added to the ShellTreeView, that is, it's structure changed. You can use it to check and suppress nodes from being added to the ShellTreeView.
Public eventBeforeInvokeCommandOnSelected Obsolete.
Assign this event to be able to control the behaviour of the control when the user double-clicks on an item to start the default action
Public eventCode exampleBeforeShellCommand
This event is fired when a shell command is to be executed, ie. via the context menu It is possible to permit the execution of the shell command by modifying the BeforeShellCommandEventArgs
Public eventBeforeShellDrop
This event is fired before a ShellTreeView executes a shell drop.
Public eventCheckStateChanged
This event is fired when the state of a checkbox was changed by the user.
Public eventFolderUpdated
This Event is triggered every time the details of a Node are updated
Public eventInitialized
Occurs when initialization of the component is completed.
Public eventNodeChecked
Occurs when the checked state of an item was changed by the user.
Public eventOperationPerformed
This event is fired after a ShellTreeView executed a shell operation like pasting.
Public eventShowOptionChanged
This event is fired after a ShellTreeView executed a shell operation like pasting.
Extension Methods
Public Extension MethodHandleNeeded
A Control extension method that ensures that the handle for a control is created.
(Defined by ExtensionMethods.)
Public Extension MethodScaledPixels
An extension method for controls: It scales the passed pixels according to the current dpi the control is displayed with.
(Defined by ExtensionMethods.)
Public Extension MethodScaleFont
A Control extension method that scales font according to the passed factor.
(Defined by ExtensionMethods.)
See Also