protected void chkMergeCells_CheckedChanged(object sender, EventArgs e)
{
if (chkMergeCells.Checked)
{
// ExStart:MergeCells
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Merging cells starting from the cell with 3rd row and 3rd column.
// 2 rows and 2 columns will be merged from the starting cell
sheet.Cells.Merge(2, 2, 2, 2);
// ExEnd:MergeCells
Label1.Text = "2 rows and 2 columns are merged starting from row 3 and column 3";
}
else
{
// ExStart:UnmergeCells
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Unmerging cells starting from the cell with 3rd row and 3rd column.
// 2 rows and 2 columns will be unmerged from the starting cell
sheet.Cells.UnMerge(2, 2, 2, 2);
// ExEnd:UnmergeCells
Label1.Text = "2 rows and 2 columns are unmerged starting from row 3 and column 3";
}
}
}