Skip to main content
A newer version of this page is available. .

TreeListNodeIterator Class

Represents an object that enables you to traverse through nodes displayed within the ASPxTreeList.

Namespace: DevExpress.Web.ASPxTreeList

Assembly: DevExpress.Web.ASPxTreeList.v19.1.dll

Declaration

public class TreeListNodeIterator

The following members return TreeListNodeIterator objects:

Remarks

Basically, you will need to write recursive code to visit all the nodes contained within the ASPxTreeList. The Nodes Iterator allows you to avoid this, and makes traversing through the nodes a trivial task. All you have to do is to create a new TreeListNodeIterator object, and use its TreeListNodeIterator.GetNext method to obtain the next node.

A start node is specified within the TreeListNodeIterator‘s constructor. To start traversing from the root node, pass the ASPxTreeList.RootNode as a parameter. The current node is returned by the TreeListNodeIterator.Current property.

To clear any explicitly defined properties and reset the TreeListNodeIterator object to its original, use the TreeListNodeIterator.Reset method.

Note

A Node Iterator can also be created using the ASPxTreeList’s ASPxTreeList.CreateNodeIterator method.

Example

This example shows how to collect the key values of all parent nodes displayed within the ASPxTreeList. The TreeListNodeIterator object is used to traverse through the nodes.

using System.Collections.Generic;
using DevExpress.Web.ASPxTreeList;

List<string> nodeKeys;
void ProcessNodes(TreeListNode startNode) {
    if (startNode == null) return;
    TreeListNodeIterator iterator = new TreeListNodeIterator(startNode);
    nodeKeys = new List<string>();
    while (iterator.Current != null) {
        GetParentNodeKey(iterator.Current);
        iterator.GetNext();
    }
}

private void GetParentNodeKey(TreeListNode node) {
    if (node != treeList.RootNode && node.HasChildren)
        nodeKeys.Add(node.Key);
}

Inheritance

See Also