Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Posts
    3

    Angry Unanswered: copying treenodes (recursive)

    Hi. I need some (example) code to copy an entire tree node structure from one treenode to another. I've tried Assign, but after Assign the new tree won't compress / expand.

  2. #2
    Join Date
    Jul 2004
    Posts
    7

    Thumbs up

    hi, this is i used in my project, try this

    kart....


    Dim flag As Boolean
    Sub Main()
    flag = True
    AddNodes (tv(0))
    Call F_Copy(0)
    End Sub

    Sub F_Copy(n As Integer)
    If flag = True Then
    tv(1).Nodes.Clear
    If UCase(Right(Trim(tv(0).Nodes(n).Key), 4)) <> ".TIF" Then
    tv(1).Nodes.Add , tvwFirst, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 1, 2
    Else
    tv(1).Nodes.Add , tvwFirst, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 3, 3
    End If
    Else
    If UCase(Right(Trim(tv(0).Nodes(n).Key), 4)) = ".TIF" Then
    tv(1).Nodes.Add tv(0).Nodes(n).Parent.Key, tvwChild, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 3, 3
    Else
    tv(1).Nodes.Add tv(0).Nodes(n).Parent.Key, tvwChild, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 1, 2
    End If
    End If
    flag = False
    ' MsgBox tv(0).Nodes(n).Text
    If tv(0).Nodes(n).Children > 0 Then
    Dim node As Integer
    node = tv(0).Nodes(n).Child.Index
    Call F_Copy(node)
    While node <> tv(0).Nodes(n).Child.LastSibling.Index
    node = tv(0).Nodes(node).Next.Index
    Call F_Copy(node)
    Wend
    End If
    End Sub

  3. #3
    Join Date
    Jul 2004
    Posts
    7

    Thumbs up

    hi, this is i used in my project, try this

    kart....


    Dim flag As Boolean
    Sub Main()
    flag = True
    AddNodes (tv(0))
    Call F_Copy(1) 'initial node
    End Sub

    Sub F_Copy(n As Integer)
    If flag = True Then
    tv(1).Nodes.Clear
    If UCase(Right(Trim(tv(0).Nodes(n).Key), 4)) <> ".TIF" Then
    tv(1).Nodes.Add , tvwFirst, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 1, 2
    Else
    tv(1).Nodes.Add , tvwFirst, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 3, 3
    End If
    Else
    If UCase(Right(Trim(tv(0).Nodes(n).Key), 4)) = ".TIF" Then
    tv(1).Nodes.Add tv(0).Nodes(n).Parent.Key, tvwChild, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 3, 3
    Else
    tv(1).Nodes.Add tv(0).Nodes(n).Parent.Key, tvwChild, tv(0).Nodes(n).Key, tv(0).Nodes(n).Text, 1, 2
    End If
    End If
    flag = False
    ' MsgBox tv(0).Nodes(n).Text
    If tv(0).Nodes(n).Children > 0 Then
    Dim node As Integer
    node = tv(0).Nodes(n).Child.Index
    Call F_Copy(node)
    While node <> tv(0).Nodes(n).Child.LastSibling.Index
    node = tv(0).Nodes(node).Next.Index
    Call F_Copy(node)
    Wend
    End If
    End Sub

  4. #4
    Join Date
    Jul 2004
    Posts
    7
    this for expaning the root node
    tv(2).Nodes(1).Expanded = True

    u want to do for all nodes then, when u add parent node, next line:
    tv(2).Nodes(<parentnode index>).Expanded = True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •