We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TreeView add nodes by name

Thread ID:





21459 Nov 10,2004 10:22 PM UTC Nov 15,2004 09:44 PM UTC WinForms 3
Tags: Tools
Asked On November 10, 2004 10:22 PM UTC

Hi, I am trying to add nodes to a Treeview control. The basic syntax is TreeNodeAdv nod = new TreeNodeAdv(NodText); tv.Nodes.Add(nod); and to add a node to the existing node you can use TreeNodeAdv nod2 = new TreeNodeAdv(NodText); nod.Nodes.Add(nod2); My question is, how do I add the second node to the first node based on the node name instead of the object itelf. Basically I know what the text is on the node that I what to add a node to, but I do not have the object reference. I can do this with a loop such as foreach (TreeNodeAdv tn in tv.Nodes) { if (tn.Text == tempText) { tn.Nodes.Add(nod2); break; } } this works, but this is obviously very inefficient, is there a better way

Administrator [Syncfusion]
Replied On November 11, 2004 11:14 PM UTC

Hi Rich, I am afraid, in the current implementation of TreeViewAdv control we do not have any built-in API to retrieve a TreeNodeAdv based on its Text. So the above approach is the only way of achieving this functionality presently. However, we could consider this as a feature request for a future release of Essential Suite. Please provide us the following information : 1. Should the Text based search be conducted over multiple levels ? 2. How should it handle a scenario which contains TreeNodeAdvs with same Text (but at different levels) ? Thanks for your interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Replied On November 12, 2004 01:57 AM UTC

I think the best idea for doing the search is to ask for a starting node, and simply search the children for that node.

Administrator [Syncfusion]
Replied On November 15, 2004 09:44 PM UTC

Hi Rich, Thanks for the update. In that case, will the above mentioned simple linear search technique meet your requirements (since we already know the parent TreeNodeAdv object)? If not, do you wish to use some other search technique ? Please let me know. We appreciate your cooperation. Regards, Guru Patwal Syncfusion, Inc.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon