CreateCustomNodeEventArgs Class

Provides data for the TreeList.CreateCustomNode event.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public class CreateCustomNodeEventArgs :
    EventArgs
Public Class CreateCustomNodeEventArgs
    Inherits 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.

Examples

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.TreeList == 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; }
   }
}

Inheritance

Object
EventArgs
CreateCustomNodeEventArgs
See Also