在DevExpress中GridControl中纵向合并单元格只需要设置
this.gridView1.OptionsView.AllowCellMerge = true;
列默认是可合并的,若设置某列不可合并可设置该列为
this.gridColumn1.OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;
private void grvDetail_CellMerge(object sender, CellMergeEventArgs e)
{
GridView view = sender as GridView;
string firstColumnFieldName = "EQPCode", secondColumnFieldName = "EQPName";
if (e.Column.FieldName == firstColumnFieldName)
{
string valueFirstColumn1 = Convert.ToString(view.GetRowCellValue(e.RowHandle1, view.Columns[firstColumnFieldName]));
string valueFirstColumn2 = Convert.ToString(view.GetRowCellValue(e.RowHandle2, view.Columns[firstColumnFieldName]));
string valueSecondColumn1 = Convert.ToString(view.GetRowCellValue(e.RowHandle1, view.Columns[secondColumnFieldName]));
string valueSecondColumn2 = Convert.ToString(view.GetRowCellValue(e.RowHandle2, view.Columns[secondColumnFieldName]));
e.Merge = valueFirstColumn1 == valueFirstColumn2 && valueSecondColumn1 == valueSecondColumn2;
e.Handled = true;
}
}