Infragistics(R) NetAdvantage(R) Windows Forms
MergedCellStyle Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridOverride Class : MergedCellStyle Property

Specifies if and how cell merging is performed. Default is resolved to Never.

Syntax

Visual Basic (Declaration) 
Public Property MergedCellStyle As MergedCellStyle
C# 
public MergedCellStyle MergedCellStyle {get; set;}

Example

Following code shows how to enable merged cells functionality. It also shows various other settings available related to the functionality.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    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.
        ' OnlyWhenSorted specifies that only sort columns will merge their cells.
        e.Layout.Override.MergedCellStyle = MergedCellStyle.OnlyWhenSorted

        ' MergedCellContentArea specifies whether to render the contents of merged
        ' cells in their visible area. Setting the property to VirtualRect will
        ' render the contents in the full area of the merged cell even if the merged
        ' cell is partially scrolled out of view.
        e.Layout.Override.MergedCellContentArea = MergedCellContentArea.VisibleRect

        ' Set the appearance of merged cells.
        e.Layout.Override.MergedCellAppearance.BackColor = Color.LightYellow
        e.Layout.Override.MergedCellAppearance.ForeColor = Color.Blue

        ' You can override these settings on a specific band by using the override
        ' object of that band.
        e.Layout.Bands(1).Override.MergedCellStyle = MergedCellStyle.Never

        ' You can also override them on a specific column as well.
        e.Layout.Bands(0).Columns(0).MergedCellStyle = MergedCellStyle.Always
        e.Layout.Bands(0).Columns(0).MergedCellContentArea = MergedCellContentArea.VirtualRect
        e.Layout.Bands(0).Columns(0).MergedCellAppearance.BackColor = Color.Aqua

        ' By default the cells are merged based on the underlying cell values.
        ' Sometimes depending on the type of column and various other format settings
        ' you may want to merge cells based on the display text. You can use
        ' MergedCellEvaluationType property to specify whether to merge cells based
        ' on the value or the display text.
        e.Layout.Bands(0).Columns(0).MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText
    End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		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.
			// OnlyWhenSorted specifies that only sort columns will merge their cells.
			e.Layout.Override.MergedCellStyle = MergedCellStyle.OnlyWhenSorted;

			// MergedCellContentArea specifies whether to render the contents of merged
			// cells in their visible area. Setting the property to VirtualRect will
			// render the contents in the full area of the merged cell even if the merged
			// cell is partially scrolled out of view.
			e.Layout.Override.MergedCellContentArea = MergedCellContentArea.VisibleRect;

			// Set the appearance of merged cells.
			e.Layout.Override.MergedCellAppearance.BackColor = Color.LightYellow;
			e.Layout.Override.MergedCellAppearance.ForeColor = Color.Blue;

			// You can override these settings on a specific band by using the override
			// object of that band.
			e.Layout.Bands[1].Override.MergedCellStyle = MergedCellStyle.Never;

			// You can also override them on a specific column as well.
			e.Layout.Bands[0].Columns[0].MergedCellStyle = MergedCellStyle.Always;
			e.Layout.Bands[0].Columns[0].MergedCellContentArea = MergedCellContentArea.VirtualRect;
			e.Layout.Bands[0].Columns[0].MergedCellAppearance.BackColor = Color.Aqua;

			// By default the cells are merged based on the underlying cell values.
			// Sometimes depending on the type of column and various other format settings
			// you may want to merge cells based on the display text. You can use
			// MergedCellEvaluationType property to specify whether to merge cells based
			// on the value or the display text.
			e.Layout.Bands[0].Columns[0].MergedCellEvaluationType = MergedCellEvaluationType.MergeSameText;
		}

Remarks

The MergedCellEvaluator property can be used for specifying custom logic for determining which cells should merge. The IMergedCellEvaluator interface should be implemented to specify the custom logic for merging cells.

See Also