Code Monkey home page Code Monkey logo

how-to-search-tree-node-based-on-its-tag-value-in-winforms-treeviewadv's Introduction

How to search tree node based on its tag value in winforms treeviewadv?

Search TreeNodeAdv based on its tag value

In TreeViewAdv, you can filter TreeNodeAdv based on its Tag value. The following code example demonstrates the same.

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 Module

The following screenshot illustrates the search TreeNodeAdv by using its Tag value.

Search TreeNodeAdv by using its tag value

how-to-search-tree-node-based-on-its-tag-value-in-winforms-treeviewadv's People

Contributors

amalrajumapathyselvam avatar sarubala20 avatar syncfusionbuild avatar vijayarasan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.