VB编程中数据库里面的数据如何合并?datagrid显示时同一日期里面多列,如何处理。。。

如图,本来想同一个日期,一列,结果现在是多列的,如何合并?看到说mshflexgrid可以合并,怎么合并?知道以日期为关键词,不知道怎么去定义、请指教。。。Private Sub Command1_Click()Adodc1.Recordset.AddNewAdodc1.Recordset("日期") = DTPicker1.ValueSelect Case Text1.TextCase "三氟溴苯" Adodc1.Recordset("三氟溴苯规格") = Text2.Text Adodc1.Recordset("三氟溴苯领料") = Text3.Text Adodc1.Recordset("三氟溴苯批号") = Text4.TextCase "精制盐酸"Adodc1.Recordset("精制盐酸规格") = Text2.TextAdodc1.Recordset("精制盐酸领料") = Text3.TextAdodc1.Recordset("精制盐酸批号") = Text4.TextEnd SelectAdodc1.Recordset.UpdateBatchMsgBox Text1.Text & "添加成功"End Sub
2026年09月28日 03:52
有1个网友回答
网友(1):

Private Sub Form_Activate()
With MSHFlexGrid1
.FixedRows = 2
.Cols = 11
.TextMatrix(0, 0) = "序号"
.TextMatrix(1, 0) = "序号"

.TextMatrix(0, 1) = "代码"
.TextMatrix(1, 1) = "代码"

.TextMatrix(0, 2) = "村名"
.TextMatrix(1, 2) = "村名"

.TextMatrix(0, 3) = "县市区"
.TextMatrix(1, 3) = "县市区"

.TextMatrix(0, 4) = "乡镇办"
.TextMatrix(1, 4) = "乡镇办"

.TextMatrix(0, 5) = "桑因面积"
.TextMatrix(0, 6) = "桑因面积"
.TextMatrix(0, 7) = "桑因面积"
.TextMatrix(0, 8) = "桑因面积"
.TextMatrix(0, 9) = "桑因面积"

.TextMatrix(1, 5) = "新植"
.TextMatrix(1, 6) = "一年生"
.TextMatrix(1, 7) = "二年生"
.TextMatrix(1, 8) = "三年生及"
.TextMatrix(1, 9) = "合计"

.TextMatrix(0, 10) = "合成地址"
.TextMatrix(1, 10) = "合成地址"
.ColAlignmentFixed(-1) = 4

.MergeCells = 3

.MergeCol(0) = True
.MergeCol(1) = True
.MergeCol(2) = True
.MergeCol(3) = True
.MergeCol(4) = True
.MergeCol(5) = False
.MergeCol(6) = False
.MergeCol(7) = False
.MergeCol(8) = False
.MergeCol(9) = False
.MergeCol(10) = True

.MergeRow(0) = True
.MergeRow(1) = False

For i = 2 To 9
For j = 0 To 10
.TextMatrix(i, j) = 1
Next
Next

End With

End Sub