Results 1 to 11 of 11

Thread: Tree View Refresh nodes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2003
    Posts
    134

    Tree View Refresh nodes

    Hey there,

    I have tried using a timer to refersh a tree view every 5 seconds but i does not work...How do i refresh a tree view every 5 seconds so that i could view new nodes...

    Thanks once again!!

  2. #2

  3. #3
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    hmm, the treeview auto refreshes doesn't it?

    Try using this.. it works for me?

    VB Code:
    1. Dim n As Node
    2. Set N = [i]TreeViewControl[/i].Nodes.Add
    3. N.Text = "This is the node Text"
    4. N.Tag = "Added: " & Now
    5. Set N = Nothing
    Wayne

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2003
    Posts
    134
    Hey there,

    Thanks for the suggestion, i have tried it out but it does not work... The nodes are added to the tree from the database

    My codes are as such

    VB Code:
    1. Private Sub Software(PC As String)
    2.  
    3. TV2.Nodes.Clear
    4.  
    5.   DBConnect
    6.    
    7.    Dim Rs As ADODB.Recordset
    8.    Set Rs = New ADODB.Recordset
    9.      
    10.    Dim i As Integer
    11.    Dim t As Integer
    12.      
    13.    Dim oNodex As Variant
    14.    Dim iIndex As Integer
    15.  
    16.    Dim cntnodes As Double
    17.    
    18.    TV2.Nodes.Clear
    19.    
    20.    frmServer.TV2.ImageList = frmServer.ImageList1
    21.    
    22.    TV2.Nodes.Add , , "main", "Software Listing", 5
    23.    
    24.    Rs.Open "Select * From Software where PC='" & PC & "'", Cn, adOpenStatic, adLockOptimistic   'where pc='" & pcname & "'", Cn, adOpenStatic, adLockOptimistic
    25.    
    26.    TV2.Nodes(TV2.Nodes.Count).Selected = True
    27.    cntnodes = TV2.Nodes.Count
    28.    
    29.        iIndex = TV2.SelectedItem.Index 'Check to see if a Node is selected
    30.      sKey = GetNextKey2() ' Get a key for the new Node
    31.      Set oNodex = TV2.Nodes.Add(iIndex, tvwChild, sKey, "Software List", 10)
    32.        
    33.      Do While Rs.EOF <> True
    34.      
    35.      If Rs!SoftwareList <> "" Then
    36.      iIndex = TV2.SelectedItem.Index
    37.      sKey1 = GetNextKey2()
    38.      Set oNodex = TV2.Nodes.Add(sKey, tvwChild, sKey1, Rs!SoftwareList, 11)
    39.      End If
    40.      Rs.MoveNext
    41.       Loop
    42.      Rs.Close
    43.      
    44.      oNodex.EnsureVisible 'make sure the child node is visible
    45.  
    46.   TV2.Refresh
    47.  
    48.  
    49.  
    50.  TV2.Nodes.Item(1).Expanded = True 'expands the 1st or ROOT node
    51.    
    52. End Sub

    How do i use the timer to refresh the tree view

  5. #5
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    try
    VB Code:
    1. TV2.Nodes.Refresh
    Wayne

  6. #6
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    BUT::

    all i use to add my nodes are:

    VB Code:
    1. ' ---------------------------------------------
    2. '  Sub Routine To Load The Users Buddy List
    3. ' ---------------------------------------------
    4. Public Sub BuddyList(Buddys As String)
    5. On Error GoTo ErrHand:
    6.  
    7.     ' Create the string arrays
    8.     Dim arrBuddies() As String, arrBuddy() As String, i As Integer
    9.    
    10.     ' reset the buddy list nodes [Clear's origional list, and add's an offline and online category]
    11.     Call modGeneral.AddNodes
    12.    
    13.     ' Split the buddies into their own little "Array Object"
    14.     arrBuddies() = Split(Buddys, " :%: ")
    15.    
    16.     With frmMain.tvBuddies.Nodes
    17.         For i = 0 To UBound(arrBuddies())
    18.             arrBuddy() = Split(arrBuddies(i), " %/ ")
    19.             modGeneral.nId = modGeneral.nId + 1
    20.             Select Case arrBuddy(0)
    21.                 Case "n":
    22.                     .Add n, tvwChild, arrBuddy(0) & modGeneral.nId, arrBuddy(1), 3
    23.                 Case "f":
    24.                     .Add f, tvwChild, arrBuddy(0) & modGeneral.nId, arrBuddy(1), 4
    25.             End Select
    26.         Next i
    27.     End With
    28.    
    29.     ' Erase the Arrays From The Memory
    30.     Erase arrBuddies()
    31.     Erase arrBuddy()
    32.    
    33. Exit Sub
    34. ErrHand:
    35.     Call DisplayError
    36. End Sub


    seams to work perfectly fine for me...

    and i do the same type of thing to load from a Database too, for stored messages....
    Wayne

  7. #7

  8. #8
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Like Martin said, if it is expanding the nodes (Which i didnt get from your question, but may be the real question, since the nodes are automatically added

    VB Code:
    1. TV2.Nodes("main").Expanded = True

    will expand your main node....

    to expand all nodes...

    VB Code:
    1. Dim n As Node
    2. For Each n In TV2.Nodes
    3.    n.Expanded=True
    4. Next n
    Wayne

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    May 2003
    Posts
    134
    Hey..

    Thanks for the reply but my question is how do i auto refresh a treeview and a tree view, i have a client server application everytime when the client sends over the info.. the tree view should be automatically be refreshed from the database.. how do i go about doing this

    Thanks!!

  10. #10

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    May 2003
    Posts
    134
    thanks it works!!

Posting Permissions

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



Click Here to Expand Forum to Full Width