Jaa


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

  1. In Design view, right-click the TreeView control and then click Edit Nodes.

  2. In the TreeView Node Editor, under Nodes, click the Add a root node button.

  3. 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.

  4. To create a child node, select the parent node in the TreeView Node Editor and then click the Add a child node button.

  5. When you have finished creating nodes, click OK.

To delete a node from the TreeView control

  1. In Design view, right-click the TreeView control and then click Edit Nodes.

    The TreeView Node Editor appears.

  2. 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.

  1. When you have finished deleting nodes, click OK.

See Also

Reference

TreeView Web Server Control Overview