DevExpress.TreeList 选节点得到所有的儿子

选节点得到所有的儿子。

      private void treeList1_Click(object sender, EventArgs e)
        {
            s = "";
            GetChildNodes(treeList1.FocusedNode);
            if (s == "")
            {
                InitMaterialListDate("and  MID=''");
            }
            else if (s.Length >= 2)
            {
                InitMaterialListDate("and  MID in('" + s.Substring(0, s.Length - 2) + ")");
            }
        }
        private void GetChildNodes(TreeListNode parentNode)
        {
            string sv = treeList1.FocusedNode.GetValue("PID").ToString();

            if (parentNode.Nodes.Count > 0)
            {
                foreach (TreeListNode node in parentNode.Nodes)
                {
                    //list.Add(node);
                    if (node.Nodes.Count == 0)
                    {
                        s = s + node.GetValue("PID").ToString() + "','";
                    }
                    if (node.Nodes.Count > 0)
                    {
                         GetChildNodes(node);
                    }
                }
            }
            if (parentNode.Nodes.Count == 0)
            {
                s = parentNode.GetValue("PID").ToString() + "','";
            }
        }

 

posted @ 2016-08-01 20:29  一枚水  阅读(1459)  评论(0)    收藏  举报