Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
If cj.text <> Nothing AndAlso dm.text <> Nothing Then
Dim dt As DataTable = DataTables("箱单数据")
Dim drs = dt.Select("款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
'Dim ggs = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'", "_sortkey")
Dim ggs() As String ={"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL","F","60","65","70","75","80","85","90","95","100","105","110","115","120","125","130","135","140","145","150","155","160","165","170","175","180","185","190","195","200"}
Dim ggs2 As List(Of String) = dt.GetValues("规格", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'")
Dim ggs3 As new List(Of String)
For Each gg As String In ggs
If ggs2.Contains(gg) Then ggs3.Add(gg)
Next
lvw.StopRedraw() '暂停绘制
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.GridLines = True '显示网格线
Dim cls() As String = {"颜色","箱号"} '定义列名
Dim wds() As String = {80,50} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = cls(i) '指定列标题
c.Name = cls(i) '指定列名
c.Width = wds(i) '指定列宽
Next
'--------------------------分组--------------------------------------
For Each zh As String In dt.GetValues("分仓信息", "款号 = '" & dm.Text & "'and 合同号 like '%" & cj.Text & "%'") '增加分组
Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
grp.Name = zh
grp.Text = zh
Next
'--------------------------------------------------------------------
For Each gg As String In ggs3
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = gg
c.Name = gg
c.Width = 30
Next
cls = new String() {"箱数","数量"} '定义列名
wds = new String() {40,40} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = cls(i) '指定列标题
c.Name = cls(i) '指定列名
c.Width = wds(i) '指定列宽
Next
Dim pdr As DataRow = Nothing
Dim xs As Double = 0
Dim xhs As String = ""
Dim sl As Double = 0
Dim pr As object = Nothing
For Each dr As DataRow In drs
If pdr Is Nothing OrElse pdr("规格") <> dr("规格") OrElse pdr("颜色") <> dr("颜色") OrElse pdr("数量") <> dr("数量")Then
If pr IsNot Nothing Then
pr("箱号") = xhs.trim("-")
pr(pdr("规格")) = pdr("数量")
pr("箱数") = xs
pr("数量") = sl
Dim arr() As String = pr("箱号").split("-")
If arr.length > 2
pr("箱号") = arr(0) & "-" & arr(arr.length - 1)
End If
End If
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
r("颜色") = dr("颜色")
xhs = dr("箱号")
xs = 1
sl = dr("数量")
pr = r
'----------------------分组----------------------------------
r.Group = dr("分仓信息")
'------------------------------------------------------------
Else
xhs &= "-" & dr("箱号")
xs += 1
sl += dr("数量")
End If
pdr = dr
Next
If drs.count > 0
Dim dr = drs(drs.count - 1)
If pr IsNot Nothing Then
pr("箱号") = xhs.trim("-")
pr(pdr("规格")) = dr("数量")
pr("箱数") = xs
pr("数量") = sl
End If
End If
lvw.ResumeRedraw
Dim sll As WinForm.Label = e.Form.Controls("Label1")
sll.Visible = True
Dim Sum As Integer
Dim Sum1 As Integer
Dim Sum2 As Integer
For Each dr As DataRow In drs
Sum = Sum + dr("数量")
sum1 = lvw.Columns.Count - 4
sum2 = lvw.Rows.Count
Next
sll.text ="合计件数: " & Sum & " 件, 共 " & sum1 & " 列 " & sum2 & " 行"
End If
可以分组了,但是这样显示不正确