c#遍历寻找节点

来源:互联网 发布:雷克萨斯rx 知乎 编辑:程序博客网 时间:2024/05/21 14:44
    public string getNodePath(string nodename, TreeNodeCollection nodes)
        {
           
           
            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].GetNodeCount(true) == 0)
                {
                    if (nodes[i].Text == nodename)
                    {
                        return nodes[i].FullPath;
                    }
                }
                else
                {
                    string s=getNodePath(nodename, nodes[i].Nodes);
                    if (s != null)
                    {
                        return s;
                    }
                }


            }
            return null;
        }
原创粉丝点击