In this article I’m going to explain how to make expandable treeview node in C# when others node is closed. Here I’m just creating a method to perform this task with name TreeView1_TreeNodeExpanded. Let’s take a look of this method code:

Foreground code:

<asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" OnTreeNodeExpanded="TreeView1_TreeNodeExpanded" ShowLines="True">

protected void TreeView1_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
              TreeNodeCollection ts = null;
             if (e.Node.Parent == null)
                 ts = ((TreeView)sender).Nodes;
                 ts = e.Node.Parent.ChildNodes;
             foreach (TreeNode node in ts)
                 if (node != e.Node)

  Thanks for shwing your interest in this article.

  Modified On Nov-30-2017 07:03:01 AM
  1. Hi zhang wei,
    Welcome to our MindStick Developers Section. Here you can share your knowledge to help others.
    You cannot upload same content in more than one section, if its done then only one of them will be approved.
    Looking forward for more Articles/Blogs from your side.
  1. Hi Haider M Rzvi,thank you for help me,my english not well ,I belive i can to do more better!

    I very Thanks!

Leave Comment