首页 > 代码库 > DevExpress TreeList利用递归绑定数据
DevExpress TreeList利用递归绑定数据
private void TreeListBind(DataTable dt, int p) { treeList1.Nodes.Clear(); if (dt.Rows.Count < 1) return; DataView dv = new DataView(dt); dv.RowFilter = "ParentFieldName=" + p; if (dv.Count < 1) return; TreeListNode Node = treeList1.AppendNode("id", null); Node.SetValue(treeListColumn1,"第一个节点名"); foreach (DataRowView dv1 in dv) { TreeListNode tn = treeList1.AppendNode(dv1["KeyFieldName"], Node); tn.SetValue(treeListColumn1, dv1["NodeName"]); tn.Tag = dv1; GetCentralChild(dt,tn, Convert.ToInt16(dv1["KeyFieldName"])); } } private void GetCentralChild(DataTable dt, TreeListNode tn, int p) { DataView dv = new DataView(dt); dv.RowFilter = "ParentFieldName=" + p; if (dv.Count < 1) return; foreach (DataRowView dv1 in dv) { TreeListNode tns = tn.TreeList.AppendNode(dv1["KeyFieldName"], tn); //TreeListNode tn = treeList1.AppendNode(dv1["KeyFieldName"], Node); tns.SetValue(treeListColumn1, dv1["NodeName"]); tns.Tag = dv1; GetCentralChild(dt, tns, Convert.ToInt16(dv1["KeyFieldName"])); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。