有没有从上到下显示的树状treeview,就像       ___________
       |Unit 1_1 | 
       |_________|
           |
    _______|__________
    |                |
____|______      ____|______  
|Unit 1_1 |     |Unit 1_2 |
|_________|     |_________|

解决方案 »

  1.   

    在codeproject上找到一个源代码,但是有点问题啊,不知道大家有没有更好用的?
      

  2.   

    想了两天终于弄出来了,不晓得楼主又得上不。/// <summary>
            /// 普通递归显示树,别忘了“using System.Data;using System.Windows.Forms;”
            /// </summary>
            /// <param name="node">添加节点到的节点</param>
            /// <param name="dbtab">DataTable,传入DataSet中的表已经测试成功</param>
            /// <param name="baseIndex">dbtab中表示本节点的表索引号</param>
            /// <param name="upIndex">dbtab中表示本节点上级节点的表索引号</param>
            public void treeNodeShow(TreeNode node, DataTable dbtab, int baseIndex, int upIndex)
            {
                for (int i = 0; i < dbtab.Rows.Count; i++)
                {
                    if (dbtab.Rows[i][upIndex].ToString() == node.Text)
                    {
                        node.Nodes.Add(dbtab.Rows[i][baseIndex].ToString());
                        treeNodeShow(node.Nodes[node.Nodes.Count - 1], dbtab, baseIndex, upIndex);
                    }
                }
            }