我们正在使用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 + =新的GridQueryCanMergeCellsEventHandler(Grid_QueryCanMergeCells);
https://www.syncfusion.com/forums/146073/can39t-merge-cells-in-gridcontrol-of-multicolumncombobox
答案 0 :(得分:0)
在提供的示例中,未为每个单元更新单元的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;
}
}