How to: Add or Delete TreeView Node Elements
You can create nodes for the TreeView control statically — that is, at design time. This is useful if you are creating a tree of fixed items.
Note
You cannot define nodes statically and bind data to the TreeView control.
To add nodes to the TreeView control
In Design view, right-click the TreeView control and then click Edit Nodes.
In the TreeView Node Editor, under Nodes, click the Add a root node button.
In the Properties grid, configure the node by setting property values. Typical properties to set include the following:
Expanded Specifies whether the node is open by default.
Text Specifies the text that is displayed by the node.
SelectAction One of several values that specifies what happens when users click the node.
To create a child node, select the parent node in the TreeView Node Editor and then click the Add a child node button.
When you have finished creating nodes, click OK.
To delete a node from the TreeView control
In Design view, right-click the TreeView control and then click Edit Nodes.
The TreeView Node Editor appears.
In the TreeView Node Editor, under Nodes, select the node that you want to delete and then click the Remove a node button.
Note When you delete a node, all of its child nodes are deleted as well.
- When you have finished deleting nodes, click OK.