Collapse other nodes when another node is selected

Posts 1–3 of 3 · Page 1 of 1
Collapse other nodes when another node is selected
Title says it all

Ex:

•Node1 [Collapse this node]
--Node2
--Node3
•Node4 [then open this one]
--Node5
•Node6 [Collapse this node]
--Node7
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim temp As TreeNode = e.Node
        For Each m As TreeNode In TreeView1.Nodes
            If Not m Is temp Then
                m.Collapse(False)
            End If
        Next
        temp.ExpandAll()
    End Sub
Quote Originally Posted by Hassan View Post
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Dim temp As TreeNode = e.Node
        For Each m As TreeNode In TreeView1.Nodes
            If Not m Is temp Then
                m.Collapse(False)
            End If
        Next
        temp.ExpandAll()
    End Sub
Thanks that will work
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?