Click or drag to resize

ShellTreeViewAddTreeNode Event

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.

Namespace:  Jam.Shell
Assembly:  ShellBrowser (in ShellBrowser.dll) Version: 7.0
Syntax
public event EventHandler<AddTreeNodeEventArgs> AddTreeNode

Value

Type: SystemEventHandlerAddTreeNodeEventArgs
Examples
This example will suppress the "My Music" library from showing up in the ShellTreeView.
C#
private void ShellTreeView1_AddTreeNode(object sender, AddTreeNodeEventArgs e)
{
    if (e.Node.AbsoluteItemIdList.SpecialFolder == ShellFolder.MyMusic)
        e.CanAdd = false;
    else if (e.Node.AbsoluteItemIdList.SpecialFolder == ShellFolder.MusicLibrary)
        e.CanAdd = false;
}
Examples
The following example will only display folders and docx-files - ShowFiles must be true for this example to work.
C#
private void ShellTreeView1_AddTreeNode2(object sender, AddTreeNodeEventArgs e)
{
    e.CanAdd = e.Node.IsFolder || (".docx".Equals(Path.GetExtension(e.FullPath), StringComparison.OrdinalIgnoreCase));
}
Examples
The TreeView supports custom icons. Set the CustomImages property to an image list and set the icon index of individual items:
C#
private void ShellTreeView1_AddTreeNodeCustomIcons(object sender, AddTreeNodeEventArgs e)
{
    if (e.Node.AbsoluteItemIdList.SpecialFolder == ShellFolder.MyMusic)
        e.Node.ImageIndex = e.Node.SelectedImageIndex = shellTreeView1.ImageList.Images.IndexOfKey("folder_music.png");

    //the following code clears the image of all root nodes in the ShellTree
    if (e.ParentNode == null)
    {
        e.Node.ImageIndex = shellTreeView1.EmptyIconIndex;
    }
}
See Also