日期:2014-05-17  浏览次数:21031 次

递归TreeView
递归,先加载部门节点,在加载上级ID节点,就是1级1级的,我写出来总有问题,请一个递归的方法。。



------解决方案--------------------

实现很简单,代码就不注释了,自己参考下吧

using System;
using System.Windows.Forms;
using System.Data;

namespace Demo
{
    public partial class Form1 : Form
    {
        TreeView treeView = new TreeView();
        public Form1()
        {
            InitializeComponent();
            SetupControl();
        }

        private void SetupControl()
        {
            DataTable dt = new DataTable();
            dt.Columns.AddRange(
            new DataColumn[]{
                    new DataColumn("员工ID"),
                    new DataColumn("上级ID"),
                    new DataColumn("员工姓名"),
                    new DataColumn("部门")
                }
            );

            string[][] data =
            {
                new string[]{"1","0","AX","生产部"},