我的数据表是四列,最后一列存在零星有数据的可能。Dim dt As DataTable
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim cmd As New SQLCommand
cmd.Connectio n N ame = "cwgl"
cmd.CommandText = "SELECT * Fro m {会计科目}"
dt = cmd.ExecuteReader()
Dim bd1 As New GroupTableBuilder("统计表1",dt)
bd1.Groups.AddDef("科目编码","会计科目编码")
bd1.Groups.AddDef("一级科目","功能类科目名称")
bd1.Groups.AddDef("二级科目","支出性质分类_一级科目")
bd1.Groups.AddDef("三级科目","支出性质分类_二级科目")
bd1.Groups.AddDef("四级科目","经济分类_一级科目")
bd1.Groups.AddDef("五级科目","经济分类_二级科目")
bd1.Groups.AddDef("六级科目","经济分类_三级科目")
Tables("会计科目设置_Table1").DataSource = bd1.BuildDataSource()
Tables("会计科目设置_table1").AutoSizeCols() '设置自动列宽
trv1.BuildTree("会计科目设置_Table1","功能类科目名称|支出性质分类_一级科目|支出性质分类_二级科目|经济分类_一级科目|经济分类_二级科目|经济分类_三级科目")
Trv1.ExpandAll()