# Cell Merging

## Content



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.

### .NET Framework

Cell merging can be enabled by setting the **AllowMerging** property of [C1FlexGrid](/componentone/api/wpf/online-flexgrid/dotnet-framework-api/C1.WPF.FlexGrid.4.6.2/C1.WPF.FlexGrid.C1FlexGrid.html) 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](https://cdn.mescius.io/document-site-files/images/3ca88af8-b501-48d7-a446-601c9251a2fb/graphics/image69_9.jpg)

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

```csharp
// 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;                              
```

### .NET

Cell merging can be enabled by setting the [AllowMerging](/componentone/api/wpf/online-flexgrid/dotnet-api/C1.WPF.Grid/C1.WPF.Grid.FlexGrid.AllowMerging.html) property of [FlexGrid](/componentone/api/wpf/online-flexgrid/dotnet-api/C1.WPF.Grid/C1.WPF.Grid.FlexGrid.html) 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](/componentone/api/wpf/online-flexgrid/dotnet-api/C1.WPF.Grid/C1.WPF.Grid.GridAllowMerging.html) enumeration to specify areas like **Cells**, **ColumnHeaders** etc. of the grid for merging.

The following image shows merged columns in a FlexGrid.

![CellMerging](https://cdn.mescius.io/document-site-files/images/3ca88af8-b501-48d7-a446-601c9251a2fb/images/cellmerging5.png)

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

```csharp
//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;
```