Home All Groups Group Topic Archive Search About
Author
10 Mar 2006 5:56 PM
sklett
I know, I know... it's rarely the case.  But here is a SIMPLE example of it
not working:

TreeNode temp = configNode.Nodes.Add("TestNode");
TreeNode[] findResult = configNode.Nodes.Find("TestNode", false);

The call to Add works, but I always get a 0 length array back from Find()

Anyone see the problem?

Author
28 Mar 2006 6:26 AM
Dave W
This casued me a lot of head scratching as well. The problem is that
Nodes.Find() searches on Key rather than Name. If you don't supply a key when
you add the node to the tree, one gets assigned for you, and since you don't
know it, you'll never be able to find the node! Since key is not unique it
would reduce confusion is the assigned key was the same as the name in my
opinion

Try

TreeNode temp = configNode.Nodes.Add("TestNodeKey", "TestNode");
TreeNode[] findResult = configNode.Nodes.Find("TestNodeKey", false);

Dave

Show quoteHide quote
"sklett" wrote:

> I know, I know... it's rarely the case.  But here is a SIMPLE example of it
> not working:
>
> TreeNode temp = configNode.Nodes.Add("TestNode");
> TreeNode[] findResult = configNode.Nodes.Find("TestNode", false);
>
> The call to Add works, but I always get a 0 length array back from Find()
>
> Anyone see the problem?
>
>
>

Bookmark and Share