Click here to Skip to main content
12,747,078 members (30,559 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.4K views
Posted 3 Feb 2012

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...

Pro
Pro

Comments and Discussions

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