This overload of the method will expand only nodes that have children. To Expand all nodes with or without children, use ExpandAll(ExpandAllType) and specify Always.
Imports Infragistics.Win.UltraWinTree Private Sub button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button11.Click Dim node As UltraTreeNode node = Me.ultraTree1.ActiveNode If node Is Nothing Then Return ' toggle the expansion state of this node and all its ' descendant nodes. If node.Expanded = True Then node.CollapseAll() Else node.ExpandAll(ExpandAllType.OnlyNodesWithChildren) End If ' Note: The following code toggles the expansion state ' of this node only (not all of its descendant nodes): 'node.Expanded = Not node.Expanded ' Note: To expand or collapse all of the nodes in the ' tree use the control's 'ExpandAll' or 'CollapseAll'. ' The following code illustrates: 'Me.ultraTree1.ExpandAll(ExpandAllType.OnlyNodesWithChildren) 'Me.ultraTree1.CollapseAll() End Sub
using Infragistics.Win.UltraWinTree; private void button11_Click(object sender, System.EventArgs e) { UltraTreeNode node = this.ultraTree1.ActiveNode; if ( node == null ) return; // toggle the expansion state of this node and all its // descendant nodes. if ( node.Expanded == true ) node.CollapseAll(); else node.ExpandAll( ExpandAllType.OnlyNodesWithChildren ); // Note: The following code toggles the expansion state // of this node only (not all of its descendant nodes): //node.Expanded = !node.Expanded; // Note: To expand or collapse all of the nodes in the // tree use the control's 'ExpandAll' or 'CollapseAll'. // The following code illustrates: //this.ultraTree1.ExpandAll( ExpandAllType.OnlyNodesWithChildren ); //this.ultraTree1.CollapseAll(); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2