Skip to content

DevExpress-Examples/winforms-treelist-custom-check-nodes-behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms TreeList - Implement custom behavior to check nodes

This example handles the TreeList.BeforeCheckNode event to do the following:

  • Set the same check state for all child nodes if the parent node's check state changes. 
  • Check the parent node if at least one child node is checked.

WinForms TreeList - Implement custom behavior to check nodes

private void treeList1_BeforeCheckNode(object sender, CheckNodeEventArgs e) {
    TreeListNode node = e.Node;
    if(node.Checked)
        node.UncheckAll();
    else node.CheckAll();
    while(node.ParentNode != null) {
        node = node.ParentNode;
        node.CheckState = AnyChildIsChecked(node) ? CheckState.Checked : CheckState.Unchecked;
    }
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Contributors 2

  •  
  •