Hi

I have a treeview where I want to perform some actions on only the
checked nodes. I don't really want to have to traverse the entire tree
every time, since it's a pretty big tree, so what I was trying to do
was keep a list of all the checked nodes - I handle the aftercheck
event so that every time a node is checked I add it to my list, and
when it's unchecked I remove it from my list.

This can become clumsy, though - for example, if I want to
programmatically uncheck some nodes, I can't just iterate through my
list and uncheck them, since that will modify the collection that I'm
enumerating through.

Is there a better approach that I'm missing?

Re: Keeping track of checked nodes in treeview by Robbe

Robbe
Thu Jul 14 20:29:59 CDT 2005

I wrote a simplistic binding solution for the windows treeview
for .NET. You could then run a query against the DataSet
instead.

http://www.eggheadcafe.com/articles/treeview_databinding.asp

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp



"Cathryn Johns" <cjohns@gmail.com> wrote in message
news:1121336010.741150.294200@g14g2000cwa.googlegroups.com...
> Hi
>
> I have a treeview where I want to perform some actions on only the
> checked nodes. I don't really want to have to traverse the entire tree
> every time, since it's a pretty big tree, so what I was trying to do
> was keep a list of all the checked nodes - I handle the aftercheck
> event so that every time a node is checked I add it to my list, and
> when it's unchecked I remove it from my list.
>
> This can become clumsy, though - for example, if I want to
> programmatically uncheck some nodes, I can't just iterate through my
> list and uncheck them, since that will modify the collection that I'm
> enumerating through.
>
> Is there a better approach that I'm missing?
>