A newer version of this page is available. Switch to the current version.

Iterate Through Nodes

  • 7 minutes to read

The Node Iterator allows you to traverse through the nodes without writing recursive code. Nodes are visited one by one starting from a specified node down to the last node contained within a tree.

The image below illustrates the sequence in which nodes are processed.


To iterate through the nodes, do the following.

Example: How to Iterate Through All Visible Nodes

This example shows how to traverse through all visible nodes to expand those nodes that have more than four child nodes. Nodes that have less than four child nodes are collapsed.

<Window xmlns:dxg="clr-namespace:DevExpress.Xpf.Grid;assembly=DevExpress.Xpf.Grid.v11.1"  x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <dxg:GridControl Name="grid" Loaded="grid_Loaded">
                <dxg:GridColumn FieldName="Name"/>
                <dxg:GridColumn FieldName="Department"/>
                <dxg:GridColumn FieldName="Position"/>
                <dxg:TreeListView Name="treeListView" AutoWidth="True"
                                  KeyFieldName="ID" ParentFieldName="ParentID"/>