Hi group
I have a requirement of merging cells according to my own custom logic which is driven by data.I checked the infragistics documentation.I found below.But certain things are not clear in the below example For Eg,i am not clear on how the function ShouldCellsBeMerged should be called in my code and how to set MergedCell style only on some columns..does anyone have a better/detailed working example for this ?
Thanks
Anusha
You can have your own custom logic for merging cells by implementing IMergedCellEvaluator interface and assigning an instance of it to the MergedCellEvaluator property of the UltraGridColumn object. The following code implements IMergedCellEvaluator on CustomMergedCellEvaluator class and sets it on the ShippedDate column in the InitializeLayout event handler of an
WinGrid is a hierarchical data bound grid control. It has full support for displaying hierarchical data provided by any data source that implements IList or ITypedList.
Toolbox Item: UltraGrid
Namespace: Infragistics.Win.UltraWinGrid
public class CustomMergedCellEvaluator: Infragistics.Win.UltraWinGrid.IMergedCellEvaluator{public CustomMergedCellEvaluator(){}public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column){// Test to make sure the Type is not DBNull since we allow the ShippedDate to be nullif (row1.GetCellValue(column).GetType().ToString() != "System.DBNull" && row2.GetCellValue(column).GetType().ToString() != "System.DBNull"){DateTime date1 = (DateTime)row1.GetCellValue(column);DateTime date2 = (DateTime)row2.GetCellValue(column);// Merge cells according to the date portions of the underlying DateTime cell// values, ignoring any time portion. For example, "1/1/2004 10:30 AM" will be// merged with "1/1/2004 1:15 AM" since the dates are the same.return date1.Date == date2.Date;}elsereturn false;}}private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){// Set the MergedCellStyle property to enable the merged cell functionality.// MergedCellStyle also specifies which columns will merge their cells.e.Layout.Override.MergedCellStyle = MergedCellStyle.Always;// MergedCellEvaluator property can be used to specify custom logic for// merging cells.e.Layout.Bands[0].Columns["ShippedDate"].MergedCellEvaluator = new CustomMergedCellEvaluator();}
public
public bool
// Test to make sure the Type is not DBNull since we allow the ShippedDate to be null
// Merge cells according to the date portions of the underlying DateTime cell// values, ignoring any time portion. For example, "1/1/2004 10:30 AM" will be// merged with "1/1/2004 1:15 AM" since the dates are the same.
return
private void
object
// Set the MergedCellStyle property to enable the merged cell functionality.// MergedCellStyle also specifies which columns will merge their cells.
// MergedCellEvaluator property can be used to specify custom logic for// merging cells.
new
It sounds like you did not attach the MergedCellEvaluator to the column or you did not enable AllowCellMerging MergedCellStyle.
HEllo
I implemented the CustomMergedCellEvaluator
however the ShouldCellsBeMerged is not being called
I tried to call the method on the initialize row event but how to get the next row to pass it to this method?
was able to make this work.Thanks