MAUI | ComponentOne
Controls / FlexGrid / Merge
In This Topic
    Merge
    In This Topic

    FlexGrid allows you to merge cells, making them span multiple rows or columns. This capability enhances the appearance and clarity of the data displayed on the grid. The effect of these settings is similar to the HTML <ROWSPAN> and <COLSPAN> tags.

    To enable cell merging, you must do two things:

    Once you have set the AllowMerging property, the FlexGrid automatically merges cells, grouping the data visually as showcased in the following image.

    Cell merging in MAUI FlexGrid

    Cell merging has several possible uses. For instance, you can use this feature to create merged table headers, merged data views, or grids where the text spills into adjacent columns.

    The following code shows how the FlexGrid appears after setting the AllowMerging property to Cells. The example uses the sample created in the Quick Start topic:

    <c1:FlexGrid x:Name="grid" AutoGenerateColumns="False" AllowMerging="Cells">
        <c1:FlexGrid.Columns>
            <c1:GridColumn Binding="FirstName" />
            <c1:GridColumn Binding="LastName" />
            <c1:GridColumn Binding="City"/>
            <c1:GridColumn Binding="Country" AllowMerging="True"/>
            <c1:GridColumn Binding="Active" />
        </c1:FlexGrid.Columns>
    </c1:FlexGrid>
    
    grid.AllowMerging = C1.Maui.Grid.GridAllowMerging.Cells;
    grid.Columns[3].AllowMerging = true;