搜索树节点,像在c#.net中一样 [英] Searching tree nodes like out look in c#.net
本文介绍了搜索树节点,像在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...........
推荐答案
您需要使用 ^ ].如果您在Google中使用"winforms treeview",那么有很多自定义选项可能更适合您的需求.
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屋!
查看全文