标题:c# winform treeView从access导入树节点问题,新手求大神修改代码!!
只看楼主
十三小主
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-4-29
 问题点数:0 回复次数:0 
c# winform treeView从access导入树节点问题,新手求大神修改代码!!
private void Main_Load(object sender, EventArgs e)
        {
            //打开后导入treeView     
            DataTable dt = OleHelp.ExecuteDataSet(OleHelp.ConnectionStringLocalTransaction, CommandType.Text, "select * from TBL_Groups", null).Tables[0];
            filltree(treeView1.Nodes[0], dt, 0);
        }
        
        
        /// <summary>
        /// 递归添加树节点方法
        /// </summary>
        /// <param name="tn">要添加子节点的当前节点</param>
        /// <param name="dt">数据表</param>
        /// <param name="id">当前节点id</param>
        ///
        public void filltree(TreeNode tn, DataTable dt, int id)
        {
            string str = " pid = " + id;
            DataRow[] dr = dt.Select(str, "id");
            if (dr.Length == 0) return;

            TreeNode ztn;

            for (int i = 0; i < dr.Length; i++)
            {
                ztn = new TreeNode(dr[i]["gkname"].ToString(), 1, 1);
                ztn.Tag = dr[i]["id"].ToString();
                tn.Nodes.Add(ztn);
                filltree(ztn, dt, Convert.ToInt16(ztn.Tag));
            }
        }
        
        添加了数据,父节点和子节点在不同的两张表中,再次打开后只导入了第一层节点,子节点该怎么导入呢?求教额!!

搜索更多相关主题的帖子: private access null 
2016-04-29 12:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-464248-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.236242 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved