Skip to main content
Tab

ASPxGridView.CustomCellMerge Event

Allows you to merge grid cells manually.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll

Declaration

public event ASPxGridViewCustomCellMergeEventHandler CustomCellMerge

Event Data

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.

Remarks

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.

CellMerging

You can handle the CustomCellMerge event to implement cell merging manually.

Note

  • The pairs of cells are processed randomly.
  • The event handler does not process neighboring cells’ indices one after another, as this event does not fire for only neighboring cells in a column.

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.

Example

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;
}

Concept

Cell Merging

Online Video

ASPxGridview - Cell Merging

Online Demo

ASPxGridView - Cell Merging

See Also