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

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);
                  
            }
            
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.