ComponentOne FlexGrid for WinForms
Merged Data Views
Using the C1FlexGrid Control > Merging Cells > Merged Data Views

Cell merging works the same way when the grid is bound to a data source. The code below shows an example for a grid bound to a data source at design time. For more information on binding to a data source, see Binding to a Data Source.

To write code in Visual Basic

Visual Basic
Copy Code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim i%
 
    ' Set up cell merging.
    _flex.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.RestrictCols
    For i = _flex.Cols.Fixed To _flex.Cols.Count - 1
        _flex.Cols(i).AllowMerging = True
    Next
End Sub

To write code in C#

C#
Copy Code
private void Form1_Load( System.object sender,  System.EventArgs e)
{
    int i;
 
    // Set up cell merging.
    _flex.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.RestrictCols;
    for (int i = _flex.Cols.Fixed; i <= _flex.Cols.Count - 1; i++)
    {
        _flex.Cols(i).AllowMerging = true;
    }
}

This is the result:


Notice how merging the cells has the effect of visually grouping the data and making the information on the table easier to understand.

Note: For an example of displaying merged data views with C1FlexGrid, see the CellMerging sample on GrapeCity website.
See Also