我认为这在树视图中很常见,它有多个级别,我有一条路径,说:
Level1 > Level2 > Level3 > Level4
如何使用路径将树视图扩展到第4级?任何内置功能?
感谢。
答案 0 :(得分:0)
完全基于文档
TreeNode mynode = treeView1.FindNode(pathToNode);
mynode.Select();
mynode.Expand();
我希望你从这里得到起点。
答案 1 :(得分:0)
如果这个问题仍然很常见......
node.ExpandParentNodes();
这将通过使用递归和扩展的父进行。
答案 2 :(得分:0)
试试这个:
Private Sub Expand(ByVal sPath As String)
Dim objNode As TreeNode
Dim preNode As TreeNode = tFolder.Nodes(0)
preNode.Expand()
Dim sSpl() As String = sPath.Replace("\\", "\").Split("\")
For i As Integer = 1 To sSpl.Length - 1
For Each objNode In preNode.Nodes
If objNode.Text = sSpl(i) Then
objNode.Expand()
preNode = objNode
Exit For
End If
Next
Next
End Sub
答案 3 :(得分:-1)
Dim n As System.Web.UI.WebControls.TreeNode = Me.tree.FindNode("Root/Parent 2/Child 2")
ExpandPath(n)
Private Shared Sub ExpandPath(ByVal node As System.Web.UI.WebControls.TreeNode)
If Not node.Parent Is Nothing Then
node.Expand()
ExpandPath(node.Parent)
Else
node.Expand()
End If
End Sub