select all childs in a Treeview

  • Thread starter Thread starter Bob Hollness
  • Start date Start date
B

Bob Hollness

Hi group. Merry Xmas one and all!!!! I hope Santa brings you all something
good. For me, I would be happy with some nice code!

If I check a node in a treeview, how do I check all childs of that node? I
wrote:


Dim Child As TreeNode = Nothing

For Each Child In myTreeView.Nodes

Child.Checked = True

Next



Now, as regular readers will know, collections are not my strong point. I
know that I have not told VB which node I am referring to when I run this
(the one I just checked is the one I want to refer to). What is missing in
my code? Or is it completely rubbish!??!!
 
The nodes of a treeview are in fact collections of collection. When you get
the event for the check you will get a reference to the node which was
checked. You then use the same construct as you have in your code but
replace the myTreeView with the node that was checked.

Hope this helps.

Lloyd Sheen
 
this is exactly what I needed! thanks!

--
Bob Hollness

-------------------------------------
I'll have a B please Bob

Lloyd Sheen said:
The nodes of a treeview are in fact collections of collection. When you
get the event for the check you will get a reference to the node which was
checked. You then use the same construct as you have in your code but
replace the myTreeView with the node that was checked.

Hope this helps.

Lloyd Sheen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top