Need for Incrementa Search Sample

2 posts, 0 answers
  1. Tooraj
    Tooraj avatar
    74 posts
    Member since:
    Aug 2010

    Posted 20 Apr 2011 Link to this post

    Hi,
    I need a Incrementa Search Sample for treeview in WinForm.
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 22 Apr 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top