控件中row(0)和row(1)为报表标题,
初始化为
————————————
序号| 金额 |数量 | 数量|
序号| 金额 |A数量|B数量|
————————————
1      10    15    15
2      10    16    15想合并为如下
——————————————
     |      |      数量    |
序号 | 金额 | ——————— 
     |      | A数量 | B数量|
——————————————
1      10       15    15
2      10       16    15
如果我再代码中写上.mergecol(1) “金额 ”能合并 但次列的数据也合并了。
关键问题就是在 把“金额”合并,但“金额”这列的数据即使有相同内容也不合并 (即两个10不合并)

解决方案 »

  1.   

    Dim i
        With fg
            .Cols = 4
            .FixedRows = 2
            .MergeCells = flexMergeFixedOnly
            .TextMatrix(1, 2) = "A(数量)"
            .TextMatrix(1, 3) = "B(数量)"
            .TextMatrix(0, 0) = "序号"
            .TextMatrix(1, 0) = "序号"
            .TextMatrix(0, 1) = "金额"
            .TextMatrix(1, 1) = "金额"
            .MergeRow(0) = True
            .MergeRow(1) = True
            For i = 0 To .Cols - 1
                Select Case i
                    Case 0, 1
                        .MergeCol(i) = True
                    Case 2, 3
                        .TextMatrix(0, i) = "数量"
                End Select
            Next i
        End With
      

  2.   

    我的网站上有类似问题的源码,你可以去看看。http://www.j2soft.cn/VB资料->查询“ 合并MsFlexGrid的单元格”;=================
    学习技巧与源码下载站:
    http://www.j2soft.cn/
    http://j2soft.008.net/
      

  3.   

    不好意思这段时间太忙了,如果 .MergeCol(1) = True  那么两个 10 会合并 不想出现这样的效果
      

  4.   

    .MergeCells = flexMergeFixedOnly
    .MergeCol(-1) = True  
    .MergeRow(-1) = True
      

  5.   

    .MergeCells = flexMergeFixedOnly
    这样就不会合并了