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.1
Syntax public event EventHandler<AddTreeNodeEventArgs> AddTreeNode
Public Event AddTreeNode As EventHandler(Of AddTreeNodeEventArgs)
public:
event EventHandler<AddTreeNodeEventArgs^>^ AddTreeNode {
void add (EventHandler<AddTreeNodeEventArgs^>^ value);
void remove (EventHandler<AddTreeNodeEventArgs^>^ value);
}
member AddTreeNode : IEvent<EventHandler<AddTreeNodeEventArgs>,
AddTreeNodeEventArgs>
Value
Type:
SystemEventHandlerAddTreeNodeEventArgsExamples
This example will suppress the "My Music" library from showing up in the ShellTreeView.
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.
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:
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");
if (e.ParentNode == null)
{
e.Node.ImageIndex = shellTreeView1.EmptyIconIndex;
}
}
See Also