469,646 Members | 1,150 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Problems with Treeview.Nodes.Clear()

Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005.

When I have some nodes in my treeview and a force to clear() all nodes then
it seems to work, because the nodes are not visible. But when I add new nodes
and I want to look for a specific item then I only get the Items from the
beginning --> something is not working with the clear() method.

Please help me!?! juvi
Feb 6 '06 #1
3 11707
You perhaps kept a reference to an old node ?

I'm using the clear method and didn't noticed anything for now...

--
Patrice

"juvi" <ju**@discussions.microsoft.com> a écrit dans le message de
news:BA**********************************@microsof t.com...
Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005.

When I have some nodes in my treeview and a force to clear() all nodes then it seems to work, because the nodes are not visible. But when I add new nodes and I want to look for a specific item then I only get the Items from the
beginning --> something is not working with the clear() method.

Please help me!?! juvi

Feb 6 '06 #2
How can I delete such references?

"Patrice" wrote:
You perhaps kept a reference to an old node ?

I'm using the clear method and didn't noticed anything for now...

--
Patrice

"juvi" <ju**@discussions.microsoft.com> a écrit dans le message de
news:BA**********************************@microsof t.com...
Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005.

When I have some nodes in my treeview and a force to clear() all nodes

then
it seems to work, because the nodes are not visible. But when I add new

nodes
and I want to look for a specific item then I only get the Items from the
beginning --> something is not working with the clear() method.

Please help me!?! juvi


Feb 6 '06 #3
More precisely my thought would be that you might have kept in a variable a
reference to the root node or something similar. If you delete then the
treeview nodes and use this reference (perhaps adding it back to the
treeview) you could likely have this behavior.

Just double check that you don't use a variable that holds a reference to
past nodes. Just make sure tthat you don't add to the new list nodes that
were kept from the previous nodes...

For exemple (not tested) :

Dim Node as TreeNode
Node=New TreeNode("A")
Node.Nodes.Add("B")
TreeView1.Nodes.Add(Node)
TreeView1.Nodes.Clear
Node=New TreeNode("Other") ' If commented you should likely still see nodes
A and B child as you add backk an old node...
TreeView1.Nodes.Add(Node)

Good luck.
--
Patrice

"juvi" <ju**@discussions.microsoft.com> a écrit dans le message de
news:B6**********************************@microsof t.com...
How can I delete such references?

"Patrice" wrote:
You perhaps kept a reference to an old node ?

I'm using the clear method and didn't noticed anything for now...

--
Patrice

"juvi" <ju**@discussions.microsoft.com> a écrit dans le message de
news:BA**********************************@microsof t.com...
Hi, I have got a problem with Treeview.Nodes.Clear() under VB2005.

When I have some nodes in my treeview and a force to clear() all nodes

then
it seems to work, because the nodes are not visible. But when I add new
nodes
and I want to look for a specific item then I only get the Items from

the beginning --> something is not working with the clear() method.

Please help me!?! juvi


Feb 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by serge calderara | last post: by
4 posts views Thread by alanrn | last post: by
5 posts views Thread by Mark Goldin | last post: by
4 posts views Thread by meh | last post: by
1 post views Thread by | last post: by
1 post views Thread by doemon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.