Back to Devexpress

ASPxGridView.CustomCellMerge Event

aspnet-devexpress-dot-web-dot-aspxgridview-a0f55440.md

latest3.9 KB
Original Source

ASPxGridView.CustomCellMerge Event

Allows you to merge grid cells manually.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event ASPxGridViewCustomCellMergeEventHandler CustomCellMerge
vb
Public Event CustomCellMerge As ASPxGridViewCustomCellMergeEventHandler

Event Data

The CustomCellMerge event's data class is ASPxGridViewCustomCellMergeEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets the currently processed column.
HandledSpecifies if merging of the currently processed cells is handled manually, so no default processing is required.
MergeSpecifies if the currently processed cells should be merged.
RowVisibleIndex1Gets the visible index of the row that contains the first cell currently being processed.
RowVisibleIndex2Gets the visible index of the row that contains the second cell currently being processed.
Value1Gets the value of the first cell currently being processed.
Value2Gets 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.

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

csharp
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

Merge Data Cells

Grid View

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace