当单击节点时,选定的节点展开,同层的其它节点关闭。。
Dim nd As WinForm.TreeNode = trv.SelectedNode
Dim id As Integer = nd.index
If e.Node.Level = 0 Then
Dim cnt As Integer = trv.Nodes.Count - 1
For i As Integer = cnt To 0 Step -1
If trv.Nodes.Count >= 0 Then
If i=id
trv.Nodes(i).Expand()
Else
trv.Nodes(i).Collapse()
End If
End If
Next
ElseIf e.Node.Level = 1 Then
Dim cnt As Integer = trv.Nodes.Count - 1
For i As Integer = cnt To 0 Step -1
If trv.Nodes.Count >= 0 Then
If i=id
trv.Nodes(i).Nodes(i).Expand()
Else
trv.Nodes(i).Nodes(i).Collapse()
End If
End If
Next
End If
这个只能做到根节点,往下的就出错了。。。