TreeListOperation.NeedsVisitChildren(TreeListNode) Method

Gets a value specifying whether the operation must be performed on the specified node's children.

Namespace: DevExpress.XtraTreeList.Nodes.Operations

Assembly: DevExpress.XtraTreeList.v20.1.dll


public virtual bool NeedsVisitChildren(
    TreeListNode node
Public Overridable Function NeedsVisitChildren(
    node As TreeListNode
) As Boolean


Name Type Description
node TreeListNode

A TreeListNode object representing the node whose child nodes are to be visited.


Type Description

true if the operation must be performed on the specified node's children; otherwise false.


When traversing through nodes using the nodes iterator, you can specify which nodes from the specified range are to be visited using the TreeListOperation.NeedsFullIteration property and the NeedsVisitChildren method. The list below describes the relationship between these two members.

  • The TreeListOperation.NeedsFullIteration property is set to true. In this case, if the NeedsVisitChildren method returns false for a parent node, this node's children are not visited.
  • The TreeListOperation.NeedsFullIteration property is set to false. In this case, only nodes that have children are visited. If the NeedsVisitChildren method returns false for a parent node, it is omitted (together with its children).

For instance, when you want to traverse through nodes that are not hidden within collapsed groups, children of collapsed nodes must not be visited. Thus, you can return the tested node's TreeListNode.Expanded property value in the implementation of the NeedsVisitChildren method.


The following sample code declares the TreeListCustomCountOperation operation class. It can be used to calculate the number of nodes whose parent contains the value of "Monterey" in its Location field.

The operation is performed by calling the TreeListNodesIterator.DoOperation method. Its result is stored to the result variable.

public class TreeListCustomCountOperation : TreeListOperation {
   private int count;

   public TreeListCustomCountOperation() {
      count = 0;
   // the parent node's Location field must contain the Monterey value
   public override bool NeedsVisitChildren(TreeListNode node) {
      return node["Location"].ToString() == "Monterey";
   // only parent nodes must be visited
   public override bool NeedsFullIteration {
      get { return false; }
   public override void Execute(TreeListNode node) {
      count += node.Nodes.Count;
   public int Count {
      get { return count; }

// performing the operation and storing its result
TreeListCustomCountOperation operation = new TreeListCustomCountOperation();
int result = operation.Count;
See Also