码迷,mamicode.com
首页 > 其他好文 > 详细

递归查询区域信息及子区域到advTree

时间:2018-01-09 20:19:15      阅读:368      评论:0      收藏:0      [点我收藏+]

标签:lte   each   send   add   eric   null   reac   ber   table   

效果:

技术分享图片

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.AdvTree;
using WinformTest.BaseServer;

namespace WinformTest
{
public partial class Form1 : Form
{
DataTable dtArea = new DataTable();
public Bitmap cache_bmp;
public Form1()
{
EncryptServerInfor.FileUploadMessage file = new EncryptServerInfor.FileUploadMessage();
file.Bmp = cache_bmp;
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Node node1 = new Node();
node1.Name = "0";
node1.Text = "所有区域";
node1.DataKey = null;
node1.TagString = "0";
advTree1.Nodes.Add(node1);

dtArea = new DataTable();
BaseServer.BaseInforClient bll = new BaseServer.BaseInforClient();

Dt_areasInfo model = new Dt_areasInfo() { Category = EnumMakeNumber.dt_areas };
BaseDtoOfDataSetymujubN2 dto = bll.QueryData(BaseServer.ExternalStructEnumOperateObj.查询, model);

if (dto.Code == 200)
{
dtArea = dto.Data.Tables[0];
BindTree(dtArea, node1);
}
//展开
advTree1.ExpandAll();
//关闭
//advTree1.CollapseAll();

}
public void BindTree(DataTable dt, Node node)
{
DataView dv = dt.DefaultView;
dv.RowFilter = " pid=" + node.Name;
DataTable dtnew = dv.ToTable();
if (dtnew.Rows.Count > 0)
foreach (DataRow item in dtnew.Rows)
{
Node nodec = new Node();
nodec.Name = item["id"].ToString();
nodec.Text = "(" + item["id"].ToString() + ")" + item["name"].ToString();
nodec.DataKey = item;
nodec.TagString = item["sort"].ToString();
node.Nodes.Add(nodec);
BindTree(dt, nodec);
}
}

private void advTree1_AfterSelect(object sender, EventArgs e)
{
if (advTree1.SelectedNode != null)
{
MessageBox.Show(advTree1.SelectedNode.Text);
}
}
}
}

递归查询区域信息及子区域到advTree

标签:lte   each   send   add   eric   null   reac   ber   table   

原文地址:https://www.cnblogs.com/famhuai/p/8252922.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!