Private Sub Form_Load() Dim i As Integer With MSFlexGrid1 .Cols = 3 .FixedCols = 0For i = 0 To 2 .TextMatrix(0, i) = "head" .TextMatrix(1, i) = "1" .ColAlignment(i) = 3 Next For i = 2 To 10 .AddItem i & vbTab & i & vbTab & i Next .MergeCells = flexMergeRestrictRows .MergeRow(0) = TrueEnd With End Sub
mshgrid.mergerow(0)=true
mshgrid.mergecells=2
前提是你三列表头是一样的
Dim i As Integer
With MSFlexGrid1
.Cols = 3
.FixedCols = 0For i = 0 To 2
.TextMatrix(0, i) = "head"
.TextMatrix(1, i) = "1"
.ColAlignment(i) = 3
Next
For i = 2 To 10
.AddItem i & vbTab & i & vbTab & i
Next
.MergeCells = flexMergeRestrictRows
.MergeRow(0) = TrueEnd With
End Sub
我的email:[email protected]
.MergeCells = flexMergeRestrictRows
'第一列1、2行合并
.Cols = 18
.TextMatrix(0, 0) = "序号"
.TextMatrix(1, 0) = "序号"
.MergeRow(0) = True
.MergeRow(1) = True
.MergeCol(0) = True
'第一行2、3两列合并
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "姓名"
.MergeRow(0) = True
.MergeCol(1) = True
.MergeCol(2) = True
End With