Skip to main content

TreeListNodesIterator.DoOperation(TreeListOperation) Method

Performs the specified operation across all nodes.

Namespace: DevExpress.XtraTreeList.Nodes.Operations

Assembly: DevExpress.XtraTreeList.v24.2.dll

Declaration

public virtual void DoOperation(
    TreeListOperation operation
)

Parameters

Name Type Description
operation TreeListOperation

A TreeListOperation descendant representing the operation to be performed.

Remarks

Use the DoOperation method to traverse through all nodes within the Tree List control. The operation performed across visited nodes is specified by a TreeListOperation descendant object passed as the parameter. Create the desired descendant, instantiate it and pass to this method. Please see the TreeListOperation class description for information on how a custom operation class can be created.

The specified operation object can prevent the iterator from visiting certain nodes. The following conditions define which nodes are visited.

For visited nodes the TreeListOperation.Execute method is called if the TreeListOperation.CanContinueIteration property returns True.

Calling the DoOperation method is equivalent to calling the TreeListNodesIterator.DoLocalOperation method with the root nodes collection as the parameter.

Example

The following sample code shows you how to create a custom operation class. It is used to calculate the maximum length of cell values within the specified column. The created TreeListMaxLengthOperation class is derived from the TreeListOperation class for this purpose.

The TreeListNodesIterator.DoOperation method is used to perform the operation. The result of calculations is written into the result variable.

public class TreeListMaxLengthOperation : TreeListOperation {
   private string fieldName;
   private int maxLength;

   public TreeListMaxLengthOperation(string fieldName) {
      this.fieldName = fieldName;
      maxLength = 0;
   }
   public override void Execute(TreeListNode node) {
      string nodeText = node[fieldName].ToString();
      if (nodeText.Length > maxLength) maxLength = nodeText.Length;
   }
   public int MaxLength {
      get { return maxLength; }
   }
}

// ...
// performing the declared operation and storing its result
TreeListMaxLengthOperation operation = new TreeListMaxLengthOperation("Department");
treeList1.NodesIterator.DoOperation(operation);
int result = operation.MaxLength;

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DoOperation(TreeListOperation) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also