Click here to Skip to main content
12,255,247 members (34,387 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

5.7K views
Posted

Select only one node in Treeview

, 3 Feb 2012 CPOL
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

You may also be interested in...

Comments and Discussions

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