我们正在使用MultiColumnComboBox控件,我们希望自定义网格以合并列(请参见上面的屏幕截图)。但是,使用以下代码似乎不起作用。QueryCanMergeCells回调似乎甚至没有被调用。
var grid = this.multiColumnComboBox1.ListBox.Grid;//Grid is SyncFusion.Windows.Forms.Grid.GridControl type
网 格。查询单元格信息 += Grid_QueryCellInfo;
为 GridControl 设置 MergeCells 方向。 网 格。TableStyle.MergeCell = GridMergeCellDirection.ColumnsInRow;//|GridMergeCellDirection.RowsInColumn;
设置网格的合并单元格行为。 网 格。模型.选项.合并单元格模式 = 网格合并细胞模式.按需计算 |GridMergeCellsMode.MergeColumnsInRow;
网 格。Model.Options.MergeCellsLayout = GridMergeCellsLayout.Grid;
网 格。QueryCanMergeCells += new GridQueryCanMergeCellsEventHandler(Grid_QueryCanMergeCells);
https://www.syncfusion.com/forums/146073/can39t-merge-cells-in-gridcontrol-of-multicolumncombobox
在提供的示例中,未为每个单元格更新单元格的"合并单元格"选项。为了克服这种情况,可以使用 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;
}
}