Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Find value in Tree Node & if found change the node color by LINQ

$
0
0

i have done the job this way

private bool SearchRecursive(IEnumerable nodes, string searchFor)
    {
        foreach (TreeNode node in nodes)
        {
            if (node.Text.ToUpper().Contains(searchFor))
            {
                treeView1.SelectedNode = node;
                node.BackColor = Color.Yellow;
            }
            if (SearchRecursive(node.Nodes, searchFor))
                return true;
        }
        return false;

i want to search data in treeview by LINQ and if data found the change the node color & expand. set the node color like selection color. if search text is empty then remove the color.

how to do the whole thing using LINQ with treeview instead of loop ? thanks


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>