Skip to main content

Expanding and Collapsing Nodes

  • 2 minutes to read

Nodes with child nodes are called parent nodes. These nodes display expand buttons allowing end-users to show/hide their children. A node's expanded state is specified by the TreeListNode.IsExpanded property.

#Expanding Nodes

To expand a node, do one of the following.

Before a node is expanded, the TreeListView.NodeExpanding event is raised. Handle this event to:

  • Cancel the action by setting the event parameter's TreeListNodeAllowEventArgs.Allow property to false;
  • Dynamically create child nodes. In this instance, when expanding a node, you do not know whether it has child nodes or not. If the node has no child nodes, hide the expand button by setting the TreeListNode.IsExpandButtonVisible property to false.

After a node has been expanded, the View fires the TreeListView.NodeExpanded event.

#Collapsing Nodes

To collapse a node, do one of the following.

Before a node is collapsed, the TreeListView.NodeCollapsing event is raised. This allows you to cancel the action by setting the event parameter's TreeListNodeAllowEventArgs.Allow property to false.

After a node has been collapsed, the View fires the TreeListView.NodeCollapsed event.