From: Derek Hart on
No idea how to do this. Have a treeview with lots of nodes. Need to loop
through the nodes, and remove ones (that have a specific tag). That is easy.
But I don't want to remove the nodes under the ones removed. I want them to
"move up" a notch, and only get deleted if they have a specific tag. Help!
So each node is looked at, but no child nodes are remove until it is their
turn to be analyzed.


From: Cor Ligthert[MVP] on
Derek,

Nice puzzle (but that are all Treeviews) seems to me a real challenge for
you.

Be aware that for all deleting in collections doing it bottom up makes
things much easier like I once learned from Armin.

For i = Count-1 (lenght-1) to 0 step -1

Success

Cor

"Derek Hart" <derekmhart(a)yahoo.com> wrote in message
news:eNuInfo5KHA.3184(a)TK2MSFTNGP05.phx.gbl...
> No idea how to do this. Have a treeview with lots of nodes. Need to loop
> through the nodes, and remove ones (that have a specific tag). That is
> easy. But I don't want to remove the nodes under the ones removed. I want
> them to "move up" a notch, and only get deleted if they have a specific
> tag. Help! So each node is looked at, but no child nodes are remove until
> it is their turn to be analyzed.
>
>
From: Family Tree Mike on
On 4/28/2010 12:04 AM, Derek Hart wrote:
> No idea how to do this. Have a treeview with lots of nodes. Need to loop
> through the nodes, and remove ones (that have a specific tag). That is easy.
> But I don't want to remove the nodes under the ones removed. I want them to
> "move up" a notch, and only get deleted if they have a specific tag. Help!
> So each node is looked at, but no child nodes are remove until it is their
> turn to be analyzed.
>
>

Think about using a while loop rather than going once through in a
foreach loop. While you can find a node who's tag is desired, then you
want to do your edits. This avoids the problems with deleting items in
a foreach loop.

--
Mike
From: Jeff Johnson on
"Derek Hart" <derekmhart(a)yahoo.com> wrote in message
news:eNuInfo5KHA.3184(a)TK2MSFTNGP05.phx.gbl...

> No idea how to do this. Have a treeview with lots of nodes. Need to loop
> through the nodes, and remove ones (that have a specific tag). That is
> easy. But I don't want to remove the nodes under the ones removed. I want
> them to "move up" a notch, and only get deleted if they have a specific
> tag. Help! So each node is looked at, but no child nodes are remove until
> it is their turn to be analyzed.

Three loops.

First, create a List(Of TreeNode). Then loop the entire tree. When you find
nodes that you want to delete, add them to the list.

Next, iterate the list. The first thing you'll need to do is iterate the
children of the active item (third loop) and set their Parent to the Parent
of the active item. This moves them "up a notch." Once that's done, delete
the node.


From: Appr3nt1c3 on
On 30 Abr, 22:13, "Jeff Johnson" <i....(a)enough.spam> wrote:
> "Derek Hart" <derekmh...(a)yahoo.com> wrote in message
>
> news:eNuInfo5KHA.3184(a)TK2MSFTNGP05.phx.gbl...
>
> > No idea how to do this. Have a treeview with lots of nodes. Need to loop
> > through the nodes, and remove ones (that have a specific tag). That is
> > easy. But I don't want to remove the nodes under the ones removed. I want
> > them to "move up" a notch, and only get deleted if they have a specific
> > tag. Help! So each node is looked at, but no child nodes are remove until
> > it is their turn to be analyzed.
>
> Three loops.
>
> First, create a List(Of TreeNode). Then loop the entire tree. When you find
> nodes that you want to delete, add them to the list.
>
> Next, iterate the list. The first thing you'll need to do is iterate the
> children of the active item (third loop) and set their Parent to the Parent
> of the active item. This moves them "up a notch." Once that's done, delete
> the node.

use two treeviews. clear the first one before the loop.
then add the nodes that you dont want to delete to the new treeview