1.修改GridView的属性
2.点击Run Design修改需要合并的列的属性
3.给GridView添加事件(以上两步不行的情况下再使用此方法)
private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e) { if (e.Column.FieldName == "Examine") { var val1 = gridView1.GetRowCellValue(e.RowHandle1, e.Column); var val2 = gridView1.GetRowCellValue(e.RowHandle2, e.Column); e.Merge = val1 == val2; e.Handled = true; } if (e.Column.FieldName == "StorageTime") { DateTime val1 = (DateTime)gridView1.GetRowCellValue(e.RowHandle1, e.Column); DateTime val2 = (DateTime)gridView1.GetRowCellValue(e.RowHandle2, e.Column); e.Merge = val1.Date == val2.Date; e.Handled = true; } }