dbTalk Databases Forums  

removing nodes in treeview

comp.databases.ms-access comp.databases.ms-access


Discuss removing nodes in treeview in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kingo
 
Posts: n/a

Default removing nodes in treeview - 07-28-2003 , 07:11 PM







I am battling with treeview - I am trying to refresh a node by removing
the children - then adding them back in.

i.e.
this works fine

If Node.Children = 0 Then _
AddChildren Node
Node.Expanded = True


can someone help me with the syntax to remove the children first?


i.e.
if node.children > 0 Then _
remove children???
Addchildren Node


this is the addchildren code bit ( yes - they really are children! )

Sub AddChildren(nodboss As Node)
On Error GoTo ErrAddChildren
Dim db As dao.Database
Dim nodCurrent As Node
Dim objTree As TreeView, temp As String
Dim strText As String, bk As String
Dim gen As Long, strgrade As String, strsql As String
Dim rstsubset As dao.Recordset
Set objTree = Me!tree.Object

strgrade = "'" & Mid(nodboss.key, 3) & "'"
strsql = "select * from students where grade = " & strgrade
Set db = CurrentDb
Set rstsubset = db.OpenRecordset(strsql, dbOpenDynaset)
rstsubset.MoveFirst
Do Until rstsubset.EOF
strText = rstsubset![NAME]
gen = 8
If rstsubset!gender = "F" Then gen = 7
If rstsubset![GRADE] = Mid(nodboss.key, 3) Then _
Set nodCurrent = objTree.Nodes.Add(nodboss, tvwChild, _
"b" & rstsubset!, strText, gen, 12)

rstsubset.MoveNext
Loop
rstsubset.Close
ExitAddChildren:
Exit Sub
ErrAddChildren:
MsgBox "Can't add child: " & Err.Description, vbCritical, _
"AddChildren(nodBoss As Node) Error:"
Resume ExitAddChildren
End Sub

--
Posted via http://dbforums.com

Reply With Quote
  #2  
Old   
DS
 
Posts: n/a

Default Re: removing nodes in treeview - 07-29-2003 , 08:53 AM






kingo <member15435 (AT) dbforums (DOT) com> wrote in news:3158906.1059437479
@dbforums.com:

Quote:
I am battling with treeview - I am trying to refresh a node by removing
the children - then adding them back in.

i.e.
this works fine

If Node.Children = 0 Then _
AddChildren Node
Node.Expanded = True


can someone help me with the syntax to remove the children first?


i.e.
if node.children > 0 Then _
remove children???
Addchildren Node
------------------------------------------
Dim pNode as Node

Set pNode = (whatever the parent node is)

Do Until pNode.Children = 0
tv.Nodes.Remove pNode.Child
Loop

Set pNode = Nothing
------------------------------------------

Simple as that.


DS




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.