Search code examples
c#devexpressxtratreelist

Is there any event which Fires when observes that a node from TreeList had the check mark checked from code?


I have a part of code which analyzes a list with checked nodes ID's, and checks into the a TreeList existing ID's. (I'm using a XtraTreeList control)

I want to calculate amount for each checked node, and I just though to make this when the node is checked.

Is there any event which observes that a node from TreeList was checked from code (programmatic)?

Cause if I check/uncheck a node with the mouse, or with the keyboard BeforeCheckNode and AfterCheckNode events takes Fire, but when i check the node from code - they don't fires.

foreach (TreeListNode item in tln) {
    var nodeID = (this.tlServices.GetDataRecordByNode(item) as __ServiceInfo).ID;
    if (svc.Select(value => value.Model.service.id).Contains(nodeID)) {
        item.Checked = true;
    }
    else if (item.HasChildren) {
        this.FindNode(item.Nodes, svc);
    }
}

Solution

  • You can use the TreeList.NodeChanged event:

    void treeList1_NodeChanged(object sender, NodeChangedEventArgs e) {
        if(e.ChangeType == NodeChangeTypeEnum.CheckedState) { 
            // do something
        }
    }