Tree view

TreeViewControl

A hierarchical tree with folder icons, checkboxes, editing, drag and drop, and a classic VB6 look.

Overview

TreeViewControl renders a list of TreeNodes with nested Children. Nodes expand on click, report selection through SelectedNodeChanged, and can carry a Tag for your own data. Two folder icon sets and UseVb6TreeStyle, which draws the dotted connector lines of the Windows common control, cover modern and migrated screens. Checkboxes, multi-select, inline editing, drag and drop, lazy loading and virtualization are parameters on the same control; this page shows the basics.

Examples

#Project explorer with a node inspector

Click a node to select it and read its properties on the right; click a folder to expand it. The switches change the folder icons and the connector lines.

Example
Razor
C#
Highland Estates Project
Site Development
Clearing & Grubbing
Rough Grading & Drainage
Underground Utilities (Wet/Dry)

Selected node

Id
root-1
Text
Highland Estates Project
Children
3
Expanded
yes
Tag
Project Root

Documentation

Parameters

ParameterTypeDefaultDescription
NodesList<TreeNode>?nullRoot nodes; each carries its Children.
SelectedNode / SelectedNodeChangedTreeNode?—Single selection, two-way.
SelectedNodeIds / CheckedNodeIds / ExpandedNodeIdsIReadOnlyList<string>?nullId lists for selection, checks and expansion, each with a …Changed callback.
OnNodeClick / OnNodeDoubleClick / OnNodeActivated / OnNodeExpandEventCallback<TreeNode>—Node events.
ToggleOnNodeClickbooltrueA click on a parent expands or collapses it.
ShowIconsbooltrueFolder and leaf icons.
FolderStyleTreeFolderStyleYellowYellow, Grey or None.
UseVb6TreeStyleboolfalseDotted connector lines and plus/minus boxes, as in the Windows common control.
TreeIndentPixelsint16Indent per level.
ShowCheckboxes / AutoCheckboolfalseA checkbox per node; AutoCheck ties parents and children.
AllowMultiSelectboolfalseMore than one selected node.
Height / CssClass / TabIndex / AriaLabelAriaLabel "Tree"Size, extra classes, tab order, accessible name.
AllowEditing · NodeEditing · NodeEditCommitting · NodeEdited—Inline rename, with veto and commit events. Not shown on this page.
AllowDragAndDrop · CanDrop · NodeMoving · NodeMoved—Drag a node to a new parent, with veto. Not shown on this page.
EnableVirtualization · ItemSizebool / floatfalse / 32Row windowing for large trees; ItemSize is the row height in px.
LoadChildrenFunc<TreeNode, CancellationToken, Task<IReadOnlyList<TreeNode>>>?nullAsync child loader for lazy trees.
NodeTemplate · FilterText · NodeComparer · NodesChanged · Error—Custom node markup, text filter, sort order, change and error callbacks.

TreeNode

PropertyTypeDefaultDescription
Idstring—Key; defaults to a random 8-character string.
Textstring""Label.
IconCss / ExpandedIconCssstring?nullLeaf or folder icon classes; the second is used while expanded.
IsExpanded / IsSelected / IsChecked / IsDisabled / IsBoldboolfalseState flags; IsIndeterminate is set by the control.
ChildrenList<TreeNode>emptyChild nodes. HasChildren is true when there are any, or when children are still to load.
HasUnloadedChildrenboolfalseMarks a node whose children come from LoadChildren on first expand; cleared once loaded.
Tagobject?nullYour own payload.

Keyboard and accessibility

Keyboard model and ARIA output are still to be checked against the source; the control exposes AriaLabel (default "Tree") and TabIndex.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.