Version

GetNodeCount Method (UltraTreeNode)

Returns the number of child nodes.
Syntax
'Declaration
 
Public Function GetNodeCount( _
   ByVal includeSubTrees As Boolean _
) As Integer
public int GetNodeCount( 
   bool includeSubTrees
)

Parameters

includeSubTrees
Determines whether to count all descendants or only the direct children of the node.

Return Value

The number of descendant nodes.
Example
The following sample code illustrates how to calculate the number of nodes in a tree.

Imports Infragistics.Win.UltraWinTree

Private Sub button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button18.Click

    Dim totalNodesInTree As Integer
    Dim nonRootNodes As Integer
    Dim node As UltraTreeNode

    ' Call the tree control's 'GetNodeCount' method 
    ' with true to get the total numder of nodes
    ' in the tree.
    totalNodesInTree = Me.ultraTree1.GetNodeCount(True)

    Debug.WriteLine("Total nodes in tree = " + totalNodesInTree.ToString())
    Debug.Indent()

    ' Get the first root node
    node = Me.ultraTree1.Nodes(0)

    While Not node Is Nothing
        ' Add in root node's descendant nodes.
        nonRootNodes += node.GetNodeCount(True)

        ' Get the next root node
        node = node.GetSibling(NodePosition.Next)
    End While

    Debug.WriteLine("root nodes = " + Me.ultraTree1.Nodes.Count.ToString())
    Debug.WriteLine("non-root nodes = " + nonRootNodes.ToString())
    Debug.IndentLevel = 0

End Sub
using System.Diagnostics;
using Infragistics.Win.UltraWinTree;

private void button18_Click(object sender, System.EventArgs e)
{

	// Call the tree control's 'GetNodeCount' method 
	// with true to get the total numder of nodes
	// in the tree.
	int totalNodesInTree = this.ultraTree1.GetNodeCount( true );

	Debug.WriteLine( "Total nodes in tree = " + totalNodesInTree.ToString());
	Debug.Indent();

	int nonRootNodes = 0;

	// Get the first root node
	UltraTreeNode node = this.ultraTree1.Nodes[0];

	while ( node != null )
	{
		// Add in root node's descendant nodes.
		nonRootNodes += node.GetNodeCount(true);

		// Get the next root node
		node = node.GetSibling( NodePosition.Next );
	}

	Debug.WriteLine( "root nodes = " + this.ultraTree1.Nodes.Count.ToString() );
	Debug.WriteLine( "non-root nodes = " + nonRootNodes.ToString());
	Debug.IndentLevel = 0;

}
Requirements

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

See Also