aspnet-devexpress-dot-web-dot-aspxgridview-a0f55440.md
Allows you to merge grid cells manually.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event ASPxGridViewCustomCellMergeEventHandler CustomCellMerge
Public Event CustomCellMerge As ASPxGridViewCustomCellMergeEventHandler
The CustomCellMerge event's data class is ASPxGridViewCustomCellMergeEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Column | Gets the currently processed column. |
| Handled | Specifies if merging of the currently processed cells is handled manually, so no default processing is required. |
| Merge | Specifies if the currently processed cells should be merged. |
| RowVisibleIndex1 | Gets the visible index of the row that contains the first cell currently being processed. |
| RowVisibleIndex2 | Gets the visible index of the row that contains the second cell currently being processed. |
| Value1 | Gets the value of the first cell currently being processed. |
| Value2 | Gets the value of the second cell currently being processed. |
Use the ASPxGridViewBehaviorSettings.AllowCellMerge or GridViewDataColumnSettings.AllowCellMerge properties to allow cell merging. In this case, the grid automatically merges neighboring cells with the same values.
You can handle the CustomCellMerge event to implement cell merging manually.
Note
To provide custom merging logic, set the Handled property to true and use the Merge property to specify if the currently processed cells should be merged. If the cells are merged, the resulting cell value is equal to Value1.
protected void grid_CustomCellMerge(object sender, DevExpress.Web.ASPxGridViewCustomCellMergeEventArgs e)
{
if (e.Column.VisibleIndex == 0)
e.Merge = true;
else if (e.Column.VisibleIndex == 1 && (e.RowVisibleIndex2 - e.RowVisibleIndex1) == 1 && e.RowVisibleIndex1 % 2 == 0)
e.Merge = true;
e.Handled = true;
}
See Also