'生成统计表代码
Dim dtb As New DataTableBuilder("统计表123")
dtb.AddDef("立面分格信息1", Gettype(String), 32)
Dim prds As List(of String) = DataTables("幕墙面材汇总表").GetValues("平面分格信息1")
For Each prd As String In prds
dtb.AddDef(prd & "_区域分组_平面分组", Gettype(String),32)
dtb.AddDef(prd & "_区域分组_立面分组", Gettype(String),32)
Next
dtb.Build()
'以上是生成临时表格式的代码,测试完成,已经调试好
For Each cus As String In DataTables("幕墙面材汇总表").GetValues("立面分格信息1")
Dim dr As DataRow = DataTables("统计表123").AddNew()
dr("立面分格信息1") = cus
For Each prd As String In prds
Dim A1s As List (Of String)
A1s= DataTables("幕墙面材汇总表").GetValues("幕墙部位分组1","安装位置2= '" & cus & "' And [安装位置1] = '" & prd & "'")
For Each A1 As String In A1s
dr(prd & "_区域分组_平面分组") =A1
Next
Dim A2s As List (Of String)
A2s= DataTables("幕墙面材汇总表").GetValues("幕墙部位分组2","安装位置2= '" & cus & "' And [安装位置1] = '" & prd & "'")
For Each A2 As String In A2s
dr(prd & "_区域分组_立面分组") =A2
Next
Next
Next
'MainTable= Tables("统计123") ’在临时表中测试没问题’
Tables("统计(测试在窗口中显示)_Table1").DataSource =datatable("统计表123") ‘设置窗口中显示
至于下拉,可以遍历表格所有列,把列名放到下拉框里供选择,没有选择的列都隐藏掉即可