This is a migrated thread and some comments may be shown as answers.

Need for Incrementa Search Sample

1 Answer 50 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Tooraj
Top achievements
Rank 1
Tooraj asked on 20 Apr 2011, 07:17 AM
Hi,
I need a Incrementa Search Sample for treeview in WinForm.

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 22 Apr 2011, 01:49 PM
Hi Tooraj,

Here is a sample code snippet for incremental search:

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
 
        for (int i = 0; i < 100; i++)
        {
            RadTreeNode node = this.radTreeView1.Nodes.Add("Parent" + i);
            for (int j = 0; j < 10; j++)
            {
                node.Nodes.Add("Child" + i + j);
            }
        }
 
        this.radTreeView1.ExpandAll();
        this.radTreeView1.SelectedNode = this.radTreeView1.Nodes[0];
    }
 
    private RadTreeNode IncrementalSearch(string text, RadTreeNode node)
    {
        if (node == null)
        {
            return null;
        }
 
        node = node.NextVisibleNode;
        while (node != null)
        {
            if (node.Text.Contains(text))
            {
                return node;
            }
 
            node = node.NextVisibleNode;
        }
 
        return null;
    }
 
    private void radButton1_Click(object sender, EventArgs e)
    {
        RadTreeNode node = IncrementalSearch("3", radTreeView1.SelectedNode);
 
        if (node != null)
        {
            radTreeView1.SelectedNode = node;
        }
    }
}

I hope this helps.

All the best,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Treeview
Asked by
Tooraj
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or