By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,224 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

Treeview nodes

P: 64
Hi there,

I have a treeview in my ms access form.
How can I get list of all nodes(Direct or indirect) under any particular node I would select.

For example my treeview is
1
a
a1
a2
b
2
x
x1
x1.1
x1.2
x2

If my starting point is 1 it should give me list like(May be I would save it in a table)

1
a
a1
a2
b

if my starting point is x then it should give me
x
x1
x1.1
x1.2
x2

Please help

Thanks,
Yogesh
Aug 16 '07 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi there,

I have a treeview in my ms access form.
How can I get list of all nodes(Direct or indirect) under any particular node I would select.

For example my treeview is
1
a
a1
a2
b
2
x
x1
x1.1
x1.2
x2

If my starting point is 1 it should give me list like(May be I would save it in a table)

1
a
a1
a2
b

if my starting point is x then it should give me
x
x1
x1.1
x1.2
x2

Please help

Thanks,
Yogesh
Hi, Yogesh.

The most suitable solution is recursive (calling itself) procedure.
something like this

Expand|Select|Wrap|Line Numbers
  1. Public Sub EnumerateChildNodes(nodStart As MSComctlLib.Node)
  2.  
  3.     Dim nodNode As MSComctlLib.Node
  4.  
  5.     Debug.Print nodStart.Text
  6.     If nodStart.Children = 0 Then Exit Sub
  7.  
  8.     Set nodNode = nodStart.Child
  9.     Do
  10.         EnumerateChildNodes nodNode
  11.         Set nodNode = nodNode.Next
  12.     Loop Until nodNode Is Nothing
  13.  
  14. End Sub
  15.  
  16.  
Aug 16 '07 #2

P: 64
Hi, Yogesh.

The most suitable solution is recursive (calling itself) procedure.
something like this

Expand|Select|Wrap|Line Numbers
  1. Public Sub EnumerateChildNodes(nodStart As MSComctlLib.Node)
  2.  
  3.     Dim nodNode As MSComctlLib.Node
  4.  
  5.     Debug.Print nodStart.Text
  6.     If nodStart.Children = 0 Then Exit Sub
  7.  
  8.     Set nodNode = nodStart.Child
  9.     Do
  10.         EnumerateChildNodes nodNode
  11.         Set nodNode = nodNode.Next
  12.     Loop Until nodNode Is Nothing
  13.  
  14. End Sub
  15.  
  16.  

Thank you so much,

This works great!!
Aug 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.