VSFLEXGRID 分组汇总

地铁 2013-12-24 01:04:02
http://img.my.csdn.net/uploads/201312/24/1387861266_8734.jpg如题,我做的分组统计汇总,总是做不起来,我希望是如EXCEL 那样
可是我用VS做的如下 http://img.my.csdn.net/uploads/201312/24/1387861282_2038.jpg

程序代码如下,望高手指教
Adodc2.ConnectionString = publicstr
Adodc2.RecordSource = "select gch,gcm,tdh,bh,scandate,sl,cc,ys,bzl,zc,stationName,scandate1 from leo033 where 1=1"
If Combo1.text <> "全部" Then
Adodc2.RecordSource = Adodc2.RecordSource + " and stationName = '" + Combo1.text + "'"

End If

If Text2.text <> "" Then
Adodc2.RecordSource = Adodc2.RecordSource + " and gch = '" + Text2.text + "'"
End If
If Text3.text <> "" Then
Adodc2.RecordSource = Adodc2.RecordSource + " and tdh = '" + Text3.text + "'"
End If
If Text4.text <> "" Then
Adodc2.RecordSource = Adodc2.RecordSource + " and bh = '" + Text4.text + "'"
End If

If Check1.Value <> 0 Then
Adodc2.RecordSource = Adodc2.RecordSource + " and scandate1 > = '" & Format(DTPicker1.Value, "yyyy-mm-dd") & "' and scandate1< = '" & Format(DTPicker2.Value, "yyyy-mm-dd") & "'"
End If
End If

Adodc2.Refresh
Call title1
MS1.Editable = flexEDKbdMouse


If Adodc2.Recordset.RecordCount > 0 Then

MS1.Rows = Adodc2.Recordset.RecordCount + 2
For i = 1 To Adodc2.Recordset.RecordCount

MS1.TextMatrix(i, 1) = Adodc2.Recordset.Fields("gch")
MS1.TextMatrix(i, 2) = Adodc2.Recordset.Fields("gcm")
MS1.TextMatrix(i, 3) = Adodc2.Recordset.Fields("tdh")
MS1.TextMatrix(i, 4) = Adodc2.Recordset.Fields("scandate")
MS1.TextMatrix(i, 5) = Adodc2.Recordset.Fields("bh")
MS1.TextMatrix(i, 6) = Adodc2.Recordset.Fields("cc")
MS1.TextMatrix(i, 7) = Adodc2.Recordset.Fields("ys") & ""
MS1.TextMatrix(i, 8) = Adodc2.Recordset.Fields("bzl")
MS1.TextMatrix(i, 9) = Adodc2.Recordset.Fields("stationname")
MS1.TextMatrix(i, 10) = Adodc2.Recordset.Fields("zc")
On Error Resume Next
MS1.TextMatrix(i, 11) = Adodc2.Recordset.Fields("sl")
qty1 = qty1 + Val(MS1.TextMatrix(i, 11))
Adodc2.Recordset.MoveNext
Next i
For i = 1 To MS1.Rows
MS1.TextMatrix(i, 0) = i
Next i
Else
MsgBox "无记录!", vbInformation, "条码扫描记录查询"
End If
Label8.Caption = Adodc2.Recordset.RecordCount & " 笔"
For i = 1 To MS1.Rows - 1
MS1.RowHeight(i) = 280 '设置行高
Next i

MS1.Cell(flexcpFontBold, MS1.Rows - 1, 0, MS1.Rows - 1, 11) = True
MS1.SetFocus
With MS1
.Redraw = flexRDNone
.AllowUserResizing = flexResizeColumns
.SubtotalPosition = flexSTBelow
.OutlineBar = flexOutlineBarSimpleLeaf
.Subtotal flexSTSum, 4, 11, , , RGB(0, 0, 255), True, "%s小计:"
.Subtotal flexSTSum, -1, 11, , , RGB(255, 0, 0), True, "总合计:"
.Redraw = True
.MergeCells = flexMergeRestrictAll
End With

For i = 0 To 4
MS1.MergeCol(i) = True
Next

End Sub
...全文
171 回复 打赏 收藏 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧