|
-
Jul 13th, 2003, 04:42 AM
#1
Thread Starter
Addicted Member
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!!
-
Jul 13th, 2003, 10:14 AM
#2
How are the new nodes added to the tree?
-
Jul 13th, 2003, 10:22 AM
#3
Frenzied Member
hmm, the treeview auto refreshes doesn't it?
Try using this.. it works for me?
VB Code:
Dim n As Node
Set N = [i]TreeViewControl[/i].Nodes.Add
N.Text = "This is the node Text"
N.Tag = "Added: " & Now
Set N = Nothing
-
Jul 13th, 2003, 11:30 AM
#4
Thread Starter
Addicted Member
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:
Private Sub Software(PC As String)
TV2.Nodes.Clear
DBConnect
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim i As Integer
Dim t As Integer
Dim oNodex As Variant
Dim iIndex As Integer
Dim cntnodes As Double
TV2.Nodes.Clear
frmServer.TV2.ImageList = frmServer.ImageList1
TV2.Nodes.Add , , "main", "Software Listing", 5
Rs.Open "Select * From Software where PC='" & PC & "'", Cn, adOpenStatic, adLockOptimistic 'where pc='" & pcname & "'", Cn, adOpenStatic, adLockOptimistic
TV2.Nodes(TV2.Nodes.Count).Selected = True
cntnodes = TV2.Nodes.Count
iIndex = TV2.SelectedItem.Index 'Check to see if a Node is selected
sKey = GetNextKey2() ' Get a key for the new Node
Set oNodex = TV2.Nodes.Add(iIndex, tvwChild, sKey, "Software List", 10)
Do While Rs.EOF <> True
If Rs!SoftwareList <> "" Then
iIndex = TV2.SelectedItem.Index
sKey1 = GetNextKey2()
Set oNodex = TV2.Nodes.Add(sKey, tvwChild, sKey1, Rs!SoftwareList, 11)
End If
Rs.MoveNext
Loop
Rs.Close
oNodex.EnsureVisible 'make sure the child node is visible
TV2.Refresh
TV2.Nodes.Item(1).Expanded = True 'expands the 1st or ROOT node
End Sub
How do i use the timer to refresh the tree view
-
Jul 13th, 2003, 11:37 AM
#5
Frenzied Member
-
Jul 13th, 2003, 11:41 AM
#6
Frenzied Member
BUT::
all i use to add my nodes are:
VB Code:
' ---------------------------------------------
' Sub Routine To Load The Users Buddy List
' ---------------------------------------------
Public Sub BuddyList(Buddys As String)
On Error GoTo ErrHand:
' Create the string arrays
Dim arrBuddies() As String, arrBuddy() As String, i As Integer
' reset the buddy list nodes [Clear's origional list, and add's an offline and online category]
Call modGeneral.AddNodes
' Split the buddies into their own little "Array Object"
arrBuddies() = Split(Buddys, " :%: ")
With frmMain.tvBuddies.Nodes
For i = 0 To UBound(arrBuddies())
arrBuddy() = Split(arrBuddies(i), " %/ ")
modGeneral.nId = modGeneral.nId + 1
Select Case arrBuddy(0)
Case "n":
.Add n, tvwChild, arrBuddy(0) & modGeneral.nId, arrBuddy(1), 3
Case "f":
.Add f, tvwChild, arrBuddy(0) & modGeneral.nId, arrBuddy(1), 4
End Select
Next i
End With
' Erase the Arrays From The Memory
Erase arrBuddies()
Erase arrBuddy()
Exit Sub
ErrHand:
Call DisplayError
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....
-
Jul 13th, 2003, 12:11 PM
#7
pnutz: Are you trying to say that the nodes don't expand? If so the refresh won't do that and you need to do something like
TV2.Nodes.Expanded = True
-
Jul 13th, 2003, 02:21 PM
#8
Frenzied Member
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:
TV2.Nodes("main").Expanded = True
will expand your main node....
to expand all nodes...
VB Code:
Dim n As Node
For Each n In TV2.Nodes
n.Expanded=True
Next n
-
Jul 13th, 2003, 08:42 PM
#9
Thread Starter
Addicted Member
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!!
-
Jul 13th, 2003, 09:07 PM
#10
Clear the treeview and then do a reload.
-
Jul 14th, 2003, 01:34 AM
#11
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|