Click here to Skip to main content
11,487,406 members (71,296 online)
Click here to Skip to main content

Tagged as

Select only one node in Treeview

, 3 Feb 2012 CPOL 4.6K
Rate this:
Please Sign up or sign in to vote.
Thanks, I am just changing False to True, And I got Automatically Check TreeView Child Nodes When Parent Is Checked.private void treeView1_AfterCheck(object sender, TreeViewEventArgs e) { if (e.Node.Checked) { ...
Thanks, I am just changing False to True, And I got Automatically Check TreeView Child Nodes When Parent Is Checked.

private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
       {
           if (e.Node.Checked)
           {
               //selectParentNodes(e.Node.Parent);
               selectChildNodes(e.Node.Nodes);
           }
           else
           {
               //DiselectParentNodes(e.Node.Parent);
               DiselectChildNodes(e.Node.Nodes);
           }
       }

private void selectChildNodes(TreeNodeCollection childes)
       {
           foreach (TreeNode oneChild in childes)
           {
               if (oneChild.Checked==false)
                   oneChild.Checked = true;
               selectChildNodes(oneChild.Nodes);
           }
       }


private void DiselectChildNodes(TreeNodeCollection childes)
       {
           foreach (TreeNode oneChild in childes)
           {
               if (oneChild.Checked)
                   oneChild.Checked = false;
               DiselectChildNodes(oneChild.Nodes);
           }
       }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 3 Feb 2012
Article Copyright 2012 by Sagotharan Jagadeeswaran
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid