Merge cells in ultragrid

1k Views Asked by At

I am trying to merge the cells in ultragrid.

I have this abc 50 23 abc 50 37 def 50 37

I want abc 50 23 37 def 50 37

his.dgDeviation.DisplayLayout.Bands[0].Columns["Price"].MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText;

his.dgDeviation.DisplayLayout.Bands[0].Columns["Price"].MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText;This explains much more what exactly i want to acheive

1

There are 1 best solutions below

0
Vivek P On

I got a solution to this

 public class CustomMergedCellEvaluator :  Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
    {
      public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column)
      {
        // check if the previous column cells are merged.
        return (row1.Cells[column.Index - 1].IsMergedWith(row2.Cells[column.Index - 1]));
      }
    }    

And then

private void dgDeviation_InitializeLayout(object sender, InitializeLayoutEventArgs e)
    {
      this.dgDeviation.DisplayLayout.Bands[0].Columns["ExcludeName"].MergedCellStyle = MergedCellStyle.Always;
      this.dgDeviation.DisplayLayout.Bands[0].Columns["ExcludeName"].MergedCellEvaluator = new CustomMergedCellEvaluator();
    }

Without a custom merge behavior, think/try what happens to checkbox column in the grid if we try to merge its cells.