Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i have a treeview in windowsform application and i need search the nodes of the treeview similar to outlook(when user types a charecter the searching will automatically starts and it will disply the matched character node) any one pls help me..........
Thanks in advance...........
Posted
Updated 21-Aug-11 21:39pm
v2

You need to use the treeview control[^]. If you google "winforms treeview" there are many customones out there that might be better suited to your needs.
 
Share this answer
 
Use another treeview which is mysearchedTreeview at same location of mytreeview ,change the visible states of the two treenodes once searching is happend

private void txbsearch_textchange(object sender,eventArgs e)
{
if(txbsearch.Text.Length>0)
{
mySearchNodeTxt(mytreeview.nodes,txb.text);
mytreeview.visible=false;
mysearchedTreeview.visible=true;
}
else
{
mytreeview.visible=true;
mysearchedTreeview.visible=false;
}
} 



private mySearchNodeTxt(TreeNodeCollection m_TreeNode, string searchtxt)
        {
            foreach (TreeNode Searchnode in m_TreeNode)
            {
                if (Searchnode.Text.ToLower().Contains(searchtxt.ToLower()))
                {
                 mysearchedTreeview.nodes.add((TreeNode)Searchnode.Clone());


                }

                SearchNodeTxt(Searchnode.Nodes, searchtxt);
                
            }
            
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900