如何判断Treeview中有某个值(Text值)存在

解决方案 »

  1.   


    private TreeNode FindNode( TreeNode tnParent, string strValue )    {        if( tnParent == null ) return null;        if( tnParent.Text == strValue ) return tnParent;         TreeNode tnRet = null;        foreach( TreeNode tn in tnParent.Nodes )        {            tnRet = FindNode( tn, strValue );            if( tnRet != null ) break;        }        return tnRet;    }
     // 程序调用,如下:        TreeNode tnRet = null;        foreach( TreeNode tn in yourTreeView.Nodes )        {            tnRet =  FindNode( tn, yourValue );            if( tnRet != null ) break;        }
      

  2.   

    遍历treeview
    http://www.cnblogs.com/Ayuann/articles/789966.html