2

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);
    }
}
John Saunders
  • 157,405
  • 24
  • 229
  • 388
mihai
  • 2,468
  • 3
  • 29
  • 54
  • 3
    Well, it is your code. So just fire your own event or call the event handler directly. – Hans Passant Nov 14 '11 at 14:03
  • The fact is that i need to calculate the amount after this TreeList is designed. I want to call the event from another class, when makes initialization. – mihai Nov 14 '11 at 14:13

2 Answers2

3

You can use the TreeList.NodeChanged event:

void treeList1_NodeChanged(object sender, NodeChangedEventArgs e) {
    if(e.ChangeType == NodeChangeTypeEnum.CheckedState) { 
        // do something
    }
}
DmitryG
  • 16,927
  • 1
  • 28
  • 51
  • 1
    @meorfi: You are always welcome! Next time, please use the [DevExpress Support Center](http://www.devexpress.com/support/center) to ask a questions or report issues, because there is no guarantee of DevExpress involvement when you use the communities, newsgroups or other communication channels. – DmitryG Nov 14 '11 at 14:34
-1

AfterCheckNode is the event.

private void _tree_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
    { TreeListNode node = e.Node as TreeListNode;}
Cannon
  • 2,441
  • 10
  • 39
  • 81