Public Sub hjdx(ByVal msfGrid As MSFlexGrid) 
    With msfGrid 
    .MergeCells = flexMergeRestrictRows 
    .MergeRow(6) = True 
    '下两格相同值,但不合并。 
    .TextMatrix(6, 3) = jf 
    .TextMatrix(6, 4) = jf + " " 
    '下两格相同值,合并。 
    .TextMatrix(6, 1) = "大写金额:" & ChMoney(.TextMatrix(6, 3)) 
    .TextMatrix(6, 2) = "大写金额:" & ChMoney(.TextMatrix(6, 3)) 
    End With 
    End Sub 

解决方案 »

  1.   

    One Example(Merge Col):
    On The Form1,Insert One MSFlexGrid Named MSFlexGrid1:
    Private Sub Form_Load()    With MSFlexGrid1
        .Rows = 10
        .Cols = 5
        .Row = 0
        .MergeCells = flexMergeRestrictColumns
        .MergeRow(0) = True
        .MergeCol(1) = True
        .MergeCol(2) = True
        .MergeCol(3) = False
        .MergeCol(4) = False
        '下两格相同值,合并。
        .TextMatrix(0, 1) = "NorthWest"
        .TextMatrix(0, 2) = "NorthWest"
        '下两格相同值,但不合并。
        .TextMatrix(0, 3) = "East"
        .TextMatrix(0, 4) = "East"
        End With
        
    End Sub
    More Information:Returns or sets a value that determines whether cells with the same contents should be grouped in a single cell spanning multiple rows or columns.Syntax
    object.MergeCells [=value]The MergeCells property syntax has these parts:Part Description 
    object An object expression that evaluates to an object in the Applies To list. 
    value An integer or constant that specifies the grouping (merging) of cells, as specified in Settings. 
    SettingsThe settings for value are:Constant Value Description 
    flexMergeNever 0 Never. The cells containing identical content are not grouped. This is the default. 
    flexMergeFree 1 Free. Cells with identical content always merge. 
    flexMergeRestrictRows 2 Restrict Rows. Only adjacent cells (to the left of the current cell) within the row containing identical content merge. 
    flexMergeRestrictColumns 3 Restrict Columns. Only adjacent cells (to the top of the current cell) within the column containing identical content merge. 
    flexMergeRestrictBoth 4 Restrict Both. Only adjacent cells within the row (to the left) or column (to the top) containing identical content merge. 
    ResThe ability to merge cells makes it possible for you to present data in a clear, concise manner. You can use cell merging in conjunction with the sorting and column order functions of the ModHFGrid.To use the cell merging capabilities of the ModHFGrid: Set MergeCells to a value other than zero. (The difference between the settings is explained in the example.)
    Set the MergeRow and MergeCol array properties to True for the rows and columns to be merged. 
    When using the cell merging capabilities, the ModHFGrid merges cells with identical content. The merging is automatically updated whenever the cell content changes.When MergeCells is set to a value other than 0 (Never), selection highlighting is automatically turned off. This is done to speed up repainting and because selection of ranges containing merged cells may lead to unexpected results.
      

  2.   

    -----------------
    |   本月进仓    |
    |---------------|
    |数量|单价| 金额|
    -----------------    With MSFlexGrid1
            .Cols = 5
            .Rows = 10
            .FixedRows = 2
            .FixedCols = 0
            .TextMatrix(0, 0) = "本月进仓"
            .TextMatrix(0, 1) = "本月进仓"
            .TextMatrix(0, 2) = "本月进仓"
            .TextMatrix(1, 0) = "数量"
            .TextMatrix(1, 1) = "单价"
            .TextMatrix(1, 2) = "金额"
            .MergeCells = flexMergeRestrictRows
            ' 下面是合并不同的形式
            '.MergeCells = flexMergeFree
            '.MergeCells = flexMergeNever
            '.MergeCells = flexMergeRestrictAll
            '.MergeCells = flexMergeRestrictColumns
            '.MergeCells = flexMergeRestrictRows
            '执行合并
            .MergeRow(0) = True
        End With
      

  3.   

    朋友!如何让MSHFlexGrid1所有的单元格,当内容相同的时候可以自动合并呢?