搜索树节点,像在c#.net中一样 [英] Searching tree nodes like out look in c#.net

查看:60
本文介绍了搜索树节点,像在c#.net中一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在Windowsform应用程序中有一个树形视图,我需要搜索类似于Outlook的树形视图的节点(当用户键入一个字符时,搜索将自动开始,并且将显示匹配的字符节点),任何人都可以帮助我... ....
在此先感谢...........

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...........

推荐答案

您需要使用
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.


在mytreeview的相同位置使用另一个树视图mysearchedTreeview,更改其可见状态搜索发生后,两个treenodes

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);
                
            }
            
        }


这篇关于搜索树节点,像在c#.net中一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆