How to search TreeNodeAdv based on its tag value in WinForms TreeViewAdv?
Search TreeNodeAdv based on its tag value
C# code snippet:
List<TreeNodeAdv> nodes;
// To search all nodes
nodes = treeViewAdv1.SearchTree().Where(n => n.Tag == "Search node").ToList();
public static class SOExtension
{
public static IEnumerable<TreeNodeAdv> SearchTree(this TreeViewAdv treeView)
{
return SearchTree(treeView.Nodes);
}
public static IEnumerable<TreeNodeAdv> SearchTree(this TreeNodeAdvCollection coll)
{
return coll.Cast<TreeNodeAdv>().Concat(coll.Cast<TreeNodeAdv>().SelectMany(x => SearchTree(x.Nodes)));
}
}VB code snippet:
Private nodes As List(Of TreeNodeAdv)
'To search all nodes
nodes = treeViewAdv1.FlattenTree().Where(Function(n) n.Tag = "Search node").ToList()
Public Module SOExtension
<System.Runtime.CompilerServices.Extension()> _
Public Function SearchTree(ByVal treeView As TreeViewAdv) As IEnumerable(Of TreeNodeAdv)
Return SearchTree(treeView.Nodes)
End Function
<System.Runtime.CompilerServices.Extension()> _
Public Function SearchTree(ByVal coll As TreeNodeAdvCollection) As IEnumerable(Of TreeNodeAdv)
Return coll.Cast(Of TreeNodeAdv)().Concat(coll.Cast(Of TreeNodeAdv)().SelectMany(Function(x) SearchTree(x.Nodes)))
End Function
End ModuleThe following screenshot illustrates the output.

Figure 1: Search TreeNodeAdv by using its Tag value
Conclusion
I hope you enjoyed learning about how to search TreeNodeAdv on its tag value in WinForms TreeViewAdv.
You can refer to our WinForms TreeViewAdv feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms TreeViewAdv example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!