当前位置:编程学习 > C#/ASP.NET >>

从指定节点的子孙节点中查找Text为nodeText的节点

/// <summary>
        /// 从指定节点的子孙节点中查找Text为nodeText的节点
        /// </summary>
        /// <param name="nodeText">要查找的节点的Text值</param>
        /// <param name="kNode">查询kNode的所有子孙节点</param>
        /// <returns></returns>
        private TreeNode FindNode(string nodeText,TreeNode kNode)
        {
                foreach (TreeNode node in kNode.Nodes)
                {
                    if (node.Text == nodeText)
                    {
                        return node;
                    }
                    else
                        if (node.Nodes.Count > 0)
                            return FindNode(nodeText, node);
                        else
                            continue;
                }
                return null;
        }

 

 

摘自 refresh

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,