Version

ShouldCellsBeMerged Method

Returns true if the cells of row1 and row2 associated with the column should be merged.
Syntax
'Declaration
 
Function ShouldCellsBeMerged( _
   ByVal row1 As UltraGridRow, _
   ByVal row2 As UltraGridRow, _
   ByVal column As UltraGridColumn _
) As Boolean
bool ShouldCellsBeMerged( 
   UltraGridRow row1,
   UltraGridRow row2,
   UltraGridColumn column
)

Parameters

row1
An UltraGridRow
row2
An UltraGridRow
column
The UltraGridColumn
Example
Following code demonstrates how you can implement IMergedCellEvaluator interface to specify custom logic for merging cells.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Class CustomMergedCellEvaluator
        Implements Infragistics.Win.UltraWinGrid.IMergedCellEvaluator

        Function ShouldCellsBeMerged(ByVal row1 As UltraGridRow, ByVal row2 As UltraGridRow, ByVal column As UltraGridColumn) As Boolean Implements IMergedCellEvaluator.ShouldCellsBeMerged
            Dim date1 As DateTime = DirectCast(row1.GetCellValue(column), DateTime)
            Dim date2 As DateTime = DirectCast(row2.GetCellValue(column), DateTime)

            ' 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
        End Function
    End Class

    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout
        ' 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 speficy custom logic for
        ' merging cells.
        e.Layout.Bands(0).Columns("ShipDate").MergedCellEvaluator = New CustomMergedCellEvaluator()
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

		private class CustomMergedCellEvaluator : Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
		{
			public bool ShouldCellsBeMerged( UltraGridRow row1, UltraGridRow row2, UltraGridColumn column )
			{
				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;
			}
		}

		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 speficy custom logic for
			// merging cells.
            e.Layout.Bands[0].Columns["ShipDate"].MergedCellEvaluator = new CustomMergedCellEvaluator( );
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also