I am struggling to find an easy way of identifying a TreeNode from its FullPath or Key/Name. I found a MSFT VB example and after carefully converting it to C# discovered that it only identifies a node after I've clicked on it, I could probably do that on my own! The Key/Name property doesn't seem to help, i.e. I still can't find a node like this: TreeNode tnRequired = myTreeView.Nodes["name"]; although the help implies this should work. It is not possible to base a class on TreeNodeCollection and using CollectionBase means pretty well re-inventing the wheel. I have something crude working using a HashTable but I have to use my own 'AddNode' function since I can't trap the Nodes.Add event. Has this been cracked by anybody or am I wasting my time looking? Many thanks :-) -- Jeff Gaines Damerham Hampshire UK It may be that your sole purpose in life is to serve as a warning to others.
Hi, You can use TreeView.Nodes.Find to find a node by its key.... What you tried doesn't work perhaps because this node is note at this level but beneath (Find allows to search iehter the current collection or to search also in child collections). -- Patrice "Jeff Gaines" <whitedragon@newsgroups.nospam> a écrit dans le message de groupe de discussion : xn0fs5c5rufasvt000@msnews.microsoft.com... > > I am struggling to find an easy way of identifying a TreeNode from its > FullPath or Key/Name. I found a MSFT VB example and after carefully > converting it to C# discovered that it only identifies a node after I've > clicked on it, I could probably do that on my own! > > The Key/Name property doesn't seem to help, i.e. I still can't find a node > like this: > > TreeNode tnRequired = myTreeView.Nodes["name"]; > > although the help implies this should work. > > It is not possible to base a class on TreeNodeCollection and using > CollectionBase means pretty well re-inventing the wheel. > > I have something crude working using a HashTable but I have to use my own > 'AddNode' function since I can't trap the Nodes.Add event. > > Has this been cracked by anybody or am I wasting my time looking? > > Many thanks :-) > > -- > Jeff Gaines Damerham Hampshire UK > It may be that your sole purpose in life is to serve as a warning to > others.
On 01/07/2008 in message Patrice wrote: >You can use TreeView.Nodes.Find to find a node by its key.... What you >tried doesn't work perhaps because this node is note at this level but >beneath (Find allows to search iehter the current collection or to search >also in child collections). Thank you Patrice, that is new to me, I'll give it a try :-) -- Jeff Gaines Damerham Hampshire UK There is no reason anyone would want a computer in their home. (Ken Olson, president Digital Equipment, 1977)