We are using a MultiColumnComboBox control and we would like to customize the grid to merge cells (see above screenshot). However, using the below code does not seem to work. The QueryCanMergeCells callback does not appear to even get called.
var grid = this.multiColumnComboBox1.ListBox.Grid; // Grid is SyncFusion.Windows.Forms.Grid.GridControl type
grid.QueryCellInfo += Grid_QueryCellInfo;
// Set MergeCells direction for the GridControl.
grid.TableStyle.MergeCell = GridMergeCellDirection.ColumnsInRow; // | GridMergeCellDirection.RowsInColumn;
// Set merge cells behavior for the Grid.
grid.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation | GridMergeCellsMode.MergeColumnsInRow;
grid.Model.Options.MergeCellsLayout = GridMergeCellsLayout.Grid;
grid.QueryCanMergeCells += new GridQueryCanMergeCellsEventHandler(Grid_QueryCanMergeCells);
private void Grid_QueryCanMergeCells(object sender, GridQueryCanMergeCellsEventArgs e)
{
// Checking whether it is already merged cells.
if (!e.Result)
{
// Sets merging for two cells with different data.
var cell1 = e.Style1.CellIdentity;
var cell2 = e.Style2.CellIdentity;
if (cell1.RowIndex == 1 && 1 == cell2.RowIndex && cell1.ColIndex == 1 & cell2.ColIndex == 2)
{
e.Result = true;
e.Handled = true;
e.Style1.CellValue = "test";
}
}
}
Attached the sample solution for reference. Thank you in advance.
Attachment:
SyncFusionDemo_f97e7981.zip