-- 作者:liuxianjie1980
-- 发布时间:2015/10/13 21:41:00
-- [求助]treeview的代码求助!(自己解决了)
代码如下:
Dim dt As DataTable Dim b As New GroupTableBuilder("发货统计表",DataTables("发货明细表")) b.Groups.AddDef("发货日期",DateGroupEnum.Year,"年") b.Groups.AddDef("发货日期",DateGroupEnum.Month,"月") b.Groups.AddDef("产品名称") b.Groups.AddDef("规格或牌号") b.Groups.AddDef("生产车间") dt = b.Build(False) \'参数设置为False,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt, "生产车间|年|月|产品名称|规格或牌号") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim Product As String = nd.DataRow("产品名称") Dim Style As String = nd.DataRow("规格或牌号") Select Case nd.Level Case 1 nd.Text = nd.text & "年" Case 2 nd.Text = nd.text & "月" Case 3 nd.Text = nd.text & "("& dt.Compute("Sum(数量)","年 = " & Year & " And 月 = " & Month & " And 产品名称=" & Product) & "公斤)" Case 4 nd.Text = nd.text & "("& dt.Compute("Sum(数量)","年 = " & Year & " And 月 = " & Month & " And 产品名称=" & Product & " And 规格或牌号=" & Style) & "公斤)" End Select Next trv.Nodes.Insert("显示所有行","显示所有行",0) trv.ResumeRedraw
按理说,没有问题啊
怎么系统提示:没有找到“某某”列呢?
[此贴子已经被作者于2015/10/13 23:25:22编辑过]
|
-- 作者:大红袍
-- 发布时间:2015/10/13 23:06:00
--
字符列,要加上单引号
Case 3 nd.Text = nd.text & "("& dt.Compute("Sum(数量)","年 = " & Year & " And 月 = " & Month & " And 产品名称=\'" & Product & "\'") & "公斤)" Case 4 nd.Text = nd.text & "("& dt.Compute("Sum(数量)","年 = " & Year & " And 月 = " & Month & " And 产品名称=\'" & Product & "\' And 规格或牌号=\'" & Style & "\'") & "公斤)"
|