The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator Syncfusion Team 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.
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.
ADAdministrator Syncfusion Team 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.