DevExpress TreeList는 귀속 바인딩 데이터 활용

4463 단어 DevExpress
 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"]));

            }

        }  

좋은 웹페이지 즐겨찾기