ComponentOne VSFlexGrid 8.0
Merged table headers

To create merged table headers, you must start by setting the MergeCells property to flexMergeFixedOnly. Then, designate the rows and columns that you want to merge using the MergeRow(), and MergeCol() properties. Finally, assign the text to the header cells so that the cells you want to merge have the same contents.

The code below shows an example:

Example Title
Copy Code
    Private Sub Form_Load()

        Dim i%

        

        ' initialize control

        fg.WordWrap = True

        fg.Cols = 9

        fg.FixedRows = 2

        fg.MergeCells = flexMergeFixedOnly

       

        ' create row headers

        fg.MergeRow(0) = True

' four cells, will merge

        fg.Cell(flexcpText, 0, 1, 0, 4) = "North" 

' four cells, will merge

fg.Cell(flexcpText, 0, 5, 0, 8) = "South"     

For i = 1 To 4

          fg.Cell(flexcpText, 1, i, 1) = "Qtr " & i

          fg.Cell(flexcpText, 1, i + 3, 1) = "Qtr " & i

        Next

       

        ' create column header

        fg.MergeCol(0) = True

' two cells, will merge

       fg.Cell(flexcpText, 0, 0, 1, 0) = "Sales by " & _ "Product"        

        ' align and autosize the cells

        fg.Cell(flexcpAlignment, 0, 0, 1, fg.Cols - 1) _  = flexAlignCenterCenter

        fg.AutoSize 1, fg.Cols - 1, False, 300

       

    End Sub

This is the result:


 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback