Nevron Open Vision Documentation
Tree View

The tree view is a widget that presents a hierarchical view of a set of items. Each item can have a number of sub items and can be expanded to show them or collapsed to hide them. To add or remove items to the tree view you can use its root item collection – Items. Each individual item also provides an item collection, which lets you easily add/remove sub items.

Properties and Events

The tree view provides the following properties:

Tree View Items

The tree view item is a widget, which consists of an expand/collapse symbol, a header and a collection of sub items.

Each tree view item provides the following properties:

The code example below demonstrates how you can create a checkable tree view item, which has an image and a text:

Advanced Tree View Item
Copy Code
NStackPanel stack = new NStackPanel();
stack.Direction = ENHVDirection.LeftToRight;
stack.HorizontalSpacing = 3;
 
stack.Add(new NCheckBox());
NImage image = new NImage(new NUri(@"C:\MyImage.png"));
stack.Add(new NImageBox(image));
stack.Add(new NLabel("Tree View Item"));
NTreeViewItem item = new NTreeViewItem(stack);
Code Examples

The code below demonstrates how to create a simple tree view with a few items and sub items and how to subscribe and handle the SelectedPathChanged event:

Tree View Creation and Event Handling
Copy Code
NTreeView treeView = new NTreeView();
for (int i = 1; i <= 5; i++)
{
    NTreeViewItem item = new NTreeViewItem("Item " + i.ToString());
    treeView.Items.Add(item);
 
    for (int j = 1; j <= 3; j++)
    {
        NTreeViewItem subItem = new NTreeViewItem("Item " + i.ToString() + "." + j.ToString());
        item.Items.Add(subItem);
    }
}
 
treeView.SelectedPathChanged += new Function<NValueChangeEventArgs>(OnTreeViewSelectedPathChanged);
 
private void OnTreeViewSelectedPathChanged(NValueChangeEventArgs arg1)
{
    // Get the tree view
    NTreeView treeView = (NTreeView)arg1.CurrentTargetNode;
 
    // Get the selected item
    NTreeViewItem selectedItem = treeView.SelectedItem;
}
Send Feedback