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

select all childs in a Treeview

P: n/a
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!??!!

--
Bob Hollness

-------------------------------------
I'll have a B please Bob
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
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!??!!

--
Bob Hollness

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

Nov 21 '05 #2

P: n/a
this is exactly what I needed! thanks!

--
Bob Hollness

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

"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:Lr********************@rogers.com...
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

"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
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!??!!

--
Bob Hollness

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


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.