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

Enum for specifying the Override's UltraGridOverride.MergedCellStyle and Column's UltraGridColumn.MergedCellStyle properties.

Syntax

Visual Basic (Declaration) 
Public Enum MergedCellStyle 
   Inherits System.Enum
C# 
public enum MergedCellStyle : System.Enum 

Members

MemberDescription
Always Always merge cells.
DefaultDefault. Default will be resolved to Never.
Never Never merge cells.
OnlyWhenSorted Merge cells only when the column is a sort column.

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;
		}

See Also