I am trying to add nodes to a Treeview control.
The basic syntax is
TreeNodeAdv nod = new TreeNodeAdv(NodText);
and to add a node to the existing node you can use
TreeNodeAdv nod2 = new TreeNodeAdv(NodText);
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)
this works, but this is obviously very inefficient, is there a better way
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.
RIRichardNovember 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.
AdministratorNovember 15, 2004 09:44 PM UTC
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.