Nodes hierarchy
To show a node inside the treeview, you need to add that node to the treeview's Root node or any other parent node in the treeview. To control the nodes hierarchy, use these node properties and methods:
- Root - root node of a treeview to which this node is bound.
- Parent - node's parent node. Returns
null
for all root-level nodes. - RealParent - identical to the Parent, but returns the treeview's Root node for all root-level nodes.
- Nodes - child nodes list.
- AttachTo - add the node to the specified parent node.
- To check whether a node is attached to the treeview, use the IsAttached property.
Index#
Every node has its own zero-based unique index within the parent's child nodes that is stored in the Index property. By changing it, you'll move the node forward or backward within the current parent.
Level#
Every node has its own nesting level that is stored in the Level property. It defines how deep the node is in the treeview nodes' hierarchy. Root-level nodes have the value 0
, root node's children - 1
, and so on.
Path#
A node may have an unlimited nesting level. To get all of a node's parents, use the Path property. It contains the FullPath property, which returns a node's parents list with the node itself as the first item in the list. Also, you can use the Parents path property, which returns only the node's parents list.
Example
RealParent#
To optimize work with a node's parent nodes, every node has two properties - Parent and RealParent. While the Parent property returns null
for root-level nodes, RealParent always returns a not-NULL value for every node. For root nodes, it returns the treeview's Root node.
TopLevelParent#
To find a node's topmost parent, use the TopLevelParent property.
Example
NextSiblingNode, PrevSiblingNode#
If you have a node instance, you can find the next or previous sibling node within the current parent using the NextSiblingNode and PrevSiblingNode node properties respectively.
NextExpandedNode, PrevExpandedNode#
The NextExpandedNode and PrevExpandedNode properties are almost equivalent to the NextSiblingNode and PrevSiblingNode properties, but allow you to get visible sibling nodes within the whole treeview.