无法在 SyncFusion 的 MultiColumnComboBox 控件中合并 GridControl 中的单元格

Can't merge cells in GridControl in MultiColumnComboBox control of SyncFusion

我们正在使用 MultiColumnComboBox 控件,我们希望自定义网格以合并列(见上面的屏幕截图)。但是,使用下面的代码似乎不起作用。 QueryCanMergeCells 回调似乎甚至没有被调用。

var grid = this.multiColumnComboBox1.ListBox.Grid; // 网格是 SyncFusion.Windows.Forms.Grid.GridControl 类型

grid.QueryCellInfo += Grid_QueryCellInfo;

// 为 GridControl 设置 MergeCells 方向。 grid.TableStyle.MergeCell = GridMergeCellDirection.ColumnsInRow; // | GridMergeCellDirection.RowsInColumn;

// 设置网格的合并单元格行为。 grid.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation | GridMergeCellsMode.MergeColumnsInRow;

grid.Model.Options.MergeCellsLayout = GridMergeCellsLayout.Grid;

grid.QueryCanMergeCells += new GridQueryCanMergeCellsEventHandler(Grid_QueryCanMergeCells);

https://www.syncfusion.com/forums/146073/can39t-merge-cells-in-gridcontrol-of-multicolumncombobox

在提供的示例中,单元格的 MergeCell 选项没有为每个单元格更新。为了克服这种情况,可以使用 QueryCellInfo 事件为每个单元格设置 MergeCell 样式。请使用以下代码,

代码示例

private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    //To set the merge cell for each cell. 
    e.Style.MergeCell = GridMergeCellDirection.ColumnsInRow; 
    if (e.ColIndex == 1 && e.RowIndex > 1) 
    { 
        //To change the cell type as CheckBox 
        e.Style.CheckBoxOptions = new GridCheckBoxCellInfo("true", "false", "", true); 
        e.Style.CellType = GridCellTypeName.CheckBox; 
    } 
}