How to expand the tree structure by full link?

I think this is a common occurrence in treeview, it has several levels, and I have a way, let's say:

Level1 > Level2 > Level3 > Level4

How can I increase the tree structure to level 4 using a path? Any built-in function?

Thanks.

+3
source share
4 answers

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
-2
source

Purely based on documentation

TreeNode mynode = treeView1.FindNode(pathToNode);
mynode.Select();
mynode.Expand();

Hope you get the starting point from here.

0
source

...

node.ExpandParentNodes();

, .

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
0

Source: https://habr.com/ru/post/1712525/


All Articles