0

i have a treeview in which i need to get the selected nodes text and its child node text(if any). I tried using AfterSelect event to get this but i only got the selected text but not the child text.. so can any one help me with this.. i am using C#, windows form application.

thanks in advance

vince

1
Contributor
1
Reply
7
Views
5 Years
Discussion Span
Last Post by vincezed
1

i got the answer by myself.... thanks

here it is

private void CallNodesSelector()
        {
            TreeNodeCollection nodes = this.treeView1.SelectedNode.Nodes;
       
            foreach (TreeNode n in nodes)
            {
                GetNodeRecursive(n);
            }
            //show();
        }

        private void GetNodeRecursive(TreeNode treeNode)
        {

            foreach (TreeNode tn in treeNode.Nodes)
            {
                GetNodeRecursive(tn);
            }
            if (treeNode.Checked == true)
            {
                 aResult.Add(treeNode.Text);
                  
            }
            
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.