向treeview中加载数据

时间:2021-02-22 10:01:57

1、获取树节点的值,用事件AfterSelect加载(id值的获取,用name来获取)

2、双击treeview控件得到

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string sql = "select * from emp";
            )//Level控件中树视图的深度
                sql = "select * from emp where dept_id=" + e.Node.Tag;//
            DataTable dt = DbAccess.MySqlHelper.getDataTable(sql);
            this.dataGridView1.DataSource = dt;
        }