FlexGrid for WPF | ComponentOne
Features / Cell Merging
In This Topic
    Cell Merging
    In This Topic

    FlexGrid supports cell merging to allow data to span across multiple rows and columns. The cell merging capability can be used to enhance the appearance of data.

    In the following section learn how to implement cell merging in FlexGrid .NET 4.5.2 and .NET 5 versions.

    Cell merging can be enabled by setting the AllowMerging property of C1FlexGrid in code. To merge columns, you need to set the AllowMerging property for each column that you want to merge to true.

    Similarly, to merge rows, set the AllowMerging property to true for each row to be merged. You can use AllowMerging Enum to specify areas like Cells, ColumnHeaders etc. of the grid for merging.

    The following image shows merged columns in a FlexGrid.

    Cell merging

    The code below illustrates merging columns (cells) containing the same country and name.

    C#
    Copy Code
    // enable merging in the scrollable area
    grid.AllowMerging = AllowMerging.Cells;
    // on columns "Country" and "FirstName"
    grid.Columns["Country"].AllowMerging = true;
    grid.Columns["FirstName"].AllowMerging = true;                              
    

    Cell merging can be enabled by setting the AllowMerging property of FlexGrid class in code. To merge columns, you need to set the AllowMerging property for each column that you want to merge to true.

    Similarly, to merge rows, set the AllowMerging property to true for each row to be merged. You can use GridAllowMerging enumeration to specify areas like Cells, ColumnHeaders etc. of the grid for merging.

    The following image shows merged columns in a FlexGrid.

    CellMerging

    The code below illustrates merging columns (cells) containing the same country and name.

    C#
    Copy Code
    //Enable merging in the scrollable area
    grid.AllowMerging = GridAllowMerging.Cells; 
    //Apply merging on columns "Country" and "FirstName"
    grid.Columns["Country"].AllowMerging = true;
    grid.Columns["FirstName"].AllowMerging = true;