469,572 Members | 1,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Multi-level TreeNode storing?

I have a form that has six possible setups for a TreeView, though after
the Tree is shown, they all act the same way. The Nodes have three or
four levels.

Repopulating the tree for another setup takes a moment due to the logic
involved in populating it. I am wondering it it would be faster if i
could "save" the nodes for later.

CopyTo and AddRange seem to support one level. Is there soimething
similar for a multi-dimensional array?

B.

Aug 9 '06 #1
2 1194
Brian Tkatch wrote:
Repopulating the tree for another setup takes a moment due to the logic
involved in populating it. I am wondering it it would be faster if i
could "save" the nodes for later.
If your "setups" (like mine) involve different "arrangements" of the
same Nodes, then yes.
Grab a reference, outside the TreeView, to each "group" node that you
want to save, clear out the TreeView and rebuild the new structure, then
add in the Nodes that you're holding, something like

Dim oGroup1 As TreeNode = tv1.Nodes( 1 )
Dim oGroup2 As TreeNode = tv1.Nodes( 2 )
.. . .
tv1.Nodes.Clear()
.. . .
Dim oNode As TreeNode _
= tv1.Nodes.Add( "Part 1" )
oNode.Nodes.Add( oGroup1 )

oNode = tv1.Nods.Add( "Part 2" )
oNode.Nodes.Add( oGroup2 )

HTH,
Phill W.
Aug 9 '06 #2

Phill W. wrote:
Brian Tkatch wrote:
Repopulating the tree for another setup takes a moment due to the logic
involved in populating it. I am wondering it it would be faster if i
could "save" the nodes for later.

If your "setups" (like mine) involve different "arrangements" of the
same Nodes, then yes.
Grab a reference, outside the TreeView, to each "group" node that you
want to save, clear out the TreeView and rebuild the new structure, then
add in the Nodes that you're holding, something like

Dim oGroup1 As TreeNode = tv1.Nodes( 1 )
Dim oGroup2 As TreeNode = tv1.Nodes( 2 )
. . .
tv1.Nodes.Clear()
. . .
Dim oNode As TreeNode _
= tv1.Nodes.Add( "Part 1" )
oNode.Nodes.Add( oGroup1 )

oNode = tv1.Nods.Add( "Part 2" )
oNode.Nodes.Add( oGroup2 )

HTH,
Phill W.
Thanx for the reply.

Actually, it is the same data, but there are three different ways to
show it, and each has two views based on a flag (thus showing different
data, the two together are everything). Two of the three views add a
newer top level, and do not show anything unless each has all three
levels. The other one has three levels, but shows everything.

So, i do not think your solution will work for me. I need to populate
all six separately.

B.

Aug 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

37 posts views Thread by ajikoe | last post: by
4 posts views Thread by Frank Jona | last post: by
5 posts views Thread by bobwansink | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.