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

CreateCustomNodeEventArgs Class

Provides data for the TreeList.CreateCustomNode event.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v18.1.dll

Declaration

public class CreateCustomNodeEventArgs :
    EventArgs

Remarks

The TreeList.CreateCustomNode event is fired when a new node is added to a Tree List and provides the opportunity to create custom nodes (TreeListNode descendants) and add them to a Tree List. The CreateCustomNodeEventArgs class provides the CreateCustomNodeEventArgs.Node property which represents the added node. The collection of nodes to which the added node belongs and the node’s unique identifier are represented by the CreateCustomNodeEventArgs.Owner and CreateCustomNodeEventArgs.NodeID properties, respectively.

CreateCustomNodeEventArgs objects are automatically created and passed to TreeList.CreateCustomNode event handlers.

Example

The following example handles the TreeList.CreateCustomNode event to add custom nodes to the Tree List. Custom nodes are represented by the CustomTLNode class which extends the functionality of the TreeListNode class. It introduces the ChildNodesCount property which returns the total number of nodes owned by the current node.

using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList.Nodes.Operations;

private void treeList1_CreateCustomNode(object sender, CreateCustomNodeEventArgs e) {
   e.Node = new CustomTLNode(e.NodeID, e.Owner);
}
// ...
public class CustomTLNode : TreeListNode {
   public CustomTLNode(int id, TreeListNodes owner) : base(id, owner) {}
   public int ChildNodesCount {
      get {
         if(this.Tree List == null) return -1;
         NodesCountOperation operation = new NodesCountOperation();
         this.TreeList.NodesIterator.DoLocalOperation(operation, this.Nodes);
         return operation.Result;
      }
   }
}
public class NodesCountOperation : TreeListOperation {
   private int result;
   public NodesCountOperation() {
      result = 0;
   }
   public override void Execute(TreeListNode node) {
      result++;
   }
   public int Result {
      get { return result; }
   }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateCustomNodeEventArgs class.

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.

Inheritance

Object
EventArgs
CreateCustomNodeEventArgs
See Also