0
votes

I have 6 nodes in a TreeView control. When the user expands one node I want other nodes to be their in collapsed condition.

How can I code this?

1

1 Answers

0
votes

before you add your nodes to parent node you should set Expanded property to false

    tv.Nodes.Add(new TreeNode() { Text="Parent", Expanded = true });
    tv.Nodes[0].ChildNodes.Add(new TreeNode() { Text = "Child1", Expanded = false });
    tv.Nodes[0].ChildNodes.Add(new TreeNode() { Text = "Child2", Expanded = false });
    tv.Nodes[0].ChildNodes.Add(new TreeNode() { Text = "Child3", Expanded = false });
    foreach (TreeNode node in tv.Nodes[0].ChildNodes)
    {
        node.ChildNodes.Add(new TreeNode() {Text="UberChild"});
    }

Mariusz