We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how can i remove UnChecked nodes and Childnodes in TreeViewAdv

Thread ID:

Created:

Updated:

Platform:

Replies:

116593 Jun 13,2014 05:20 AM UTC Jun 17,2014 12:24 PM UTC WinForms 1
loading
Tags: TreeViewAdv
Narry
Asked On June 13, 2014 05:20 AM UTC

I did it in .Net treeview can any one can replace my code with syncfusion controls code.... 

void RemoveCheckedNodes(TreeNodeCollection nodes)
        {
            List<TreeNode> checkedNodes = new List<TreeNode>();

            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    checkedNodes.Add(node);
                }
                else
                {
                    RemoveCheckedNodes(nodes.ChildNodes);
                }
            }

            foreach (TreeNode checkedNode in checkedNodes)
            {
                nodes.Remove(checkedNode);
            }
        }

thanks in Advance

Saravanan T [Syncfusion]
Replied On June 17, 2014 12:24 PM UTC

Hi Narry,

Thank you for using Syncfusion Product,

We would like to let you know that your requirement of removing Unchecked nodes and Childnodes in TreeViewAdv can be achieved by adding the below code snippet. Please refer this and attached sample regarding TreeViewAdv.

Code Snippet[C#]:
 void RemoveCheckedNodes(TreeNodeAdvCollection nodes)
        {
            List<TreeNodeAdv> checkedNodes = new List<TreeNodeAdv>();

            foreach (TreeNodeAdv node in nodes)
            {
                if (!node.Checked)
                {
                    checkedNodes.Add(node);
                }
                else
                {
                    RemoveCheckedNodes(nodes[0].Nodes);
                }
            }

            foreach (TreeNodeAdv checkedNode in checkedNodes)
            {
                nodes.Remove(checkedNode);
            }
        }
 private void button1_Click(object sender, EventArgs e)
        {
            RemoveCheckedNodes(treeViewAdv1.Nodes);
        }

Please let us know if you need any further assistance,

Regards,
T.Saravanan

Attachment: WindowsFormsApplication263_(2)_6c18eb31.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;