Version

UltraGridLayout Class

An object that maintains the structure and settings for an UltraGrid, UltraCombo or UltraDropDown control.
Syntax
'Declaration
 
Public Class UltraGridLayout 
   Inherits Infragistics.Shared.KeyedSubObjectBase
   Implements Infragistics.Shared.IKeyedSubObject, Infragistics.Shared.IKeyedSubObjectEx, Infragistics.Win.IImageListProvider, Infragistics.Win.ISupportPresets 
public class UltraGridLayout : Infragistics.Shared.KeyedSubObjectBase, Infragistics.Shared.IKeyedSubObject, Infragistics.Shared.IKeyedSubObjectEx, Infragistics.Win.IImageListProvider, Infragistics.Win.ISupportPresets  
Remarks

The DisplayLayout property of an object is used to access the UltraGridLayout object that determines the settings of various properties related to the appearance and behavior of the object. The UltraGridLayout object provides a simple way to maintain multiple layouts for the grid and apply them as needed. You can also save grid layouts to disk, the registry or a storage stream and restore them later.

The UltraGridLayout object has properties such as Appearance and Override, so the UltraGridLayout object has sub-objects of these types, and their settings are included as part of the layout. However, the information that is actually persisted depends on how the settings of these properties were assigned. If the properties were set using the UltraGridLayout object's intrinsic objects, the property settings will be included as part of the layout. However, if a named object was assigned to the property from a collection, the layout will only include the reference into the collection, not the actual settings of the named object. (For an overview of the difference between named and intrinsic objects, please see the Appearanceproperty.

For example, if the Layout object's Appearance property is used to set values for the intrinsic Appearance object like this:

UltraGrid1.DisplayLayout.Appearance.ForeColor = vbBlue

Then the setting (in this case, ForeColor) will be included as part of the layout, and will be saved, loaded and applied along with the other layout data. However, suppose you apply the settings of a named object to the UltraGridLayout's Appearance property in this manner:

UltraWinGrid1.Appearances.Add "New1"

UltraWinGrid1.Appearances("New1").ForeColor = vbBlue

UltraWinGrid1.Layout.Appearance = UltraWinGrid1.Appearances("New1")

In this case, the ForeColor setting will not be persisted as part of the layout. Instead, the layout will include a reference to the "New1" Appearance object and use whatever setting is present in that object when the layout is applied.

By default, the layout includes a copy of the entire Appearances collection, so if the layout is saved and restored using the default settings, the object should always be present in the collection when it is referred to. However, it is possible to use the Load and Save methods of the UltraGridLayout object in such a way that the collection will not be re-created when the layout is applied. If this is the case, and the layout contains a reference to a nonexistent object, the default settings for that object's properties will be used.

The following sample code shows how to set some UltraGridLayout properties in the InitializeLayout event.

            Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
            
                e.Layout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.MultiBand
                e.Layout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy
            
                e.Layout.AutoFitStyle = AutoFitStyle.ResizeAllColumns
                e.Layout.MaxRowScrollRegions = 3
                e.Layout.CaptionAppearance.ForeColor = Color.Red
            
                e.Layout.GroupByBox.BandLabelBorderStyle = Infragistics.Win.UIElementBorderStyle.Dotted
                e.Layout.GroupByBox.ShowBandLabels = Infragistics.Win.UltraWinGrid.ShowBandLabels.IntermediateBandsOnly
            
                e.Layout.Override.CellAppearance.BackColor = Color.White
                e.Layout.Override.CellAppearance.BackColor2 = Color.Blue
                e.Layout.Override.CellAppearance.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump
            
                e.Layout.AddNewBox.Hidden = False
                e.Layout.AddNewBox.Style = Infragistics.Win.UltraWinGrid.AddNewBoxStyle.Compact
                e.Layout.AddNewBox.ButtonStyle = Infragistics.Win.UIElementButtonStyle.PopupBorderless
                e.Layout.AddNewBox.ButtonConnectorStyle = Infragistics.Win.UIElementBorderStyle.Dotted
            
            End Sub
            
Example
Following code shows some of the information available in InitializeLayout event.

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

      ' InitializeLayout gets fired for the UltraGrid's layout as well as when printing.
      If e.Layout.IsPrintLayout Then
          ' This is a print layout. When printing, use White as the background color.
          e.Layout.Appearance.BackColor = Color.White

          ' Hide the second band (band 1) when printing so rows from that band and its
          ' descendant bands don't show up in the print.
          e.Layout.Bands(1).Hidden = True
      Else
          e.Layout.Appearance.BackColor = Color.Gray
      End If

      ' Set the behaviour of tab keys in the UltraGrid.
      Me.UltraGrid1.DisplayLayout.TabNavigation = TabNavigation.NextCell

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{

	// InitializeLayout gets fired for the UltraGrid's layout as well as when printing.
	if ( e.Layout.IsPrintLayout )
	{
		// This is a print layout. When printing, use White as the background color.
		e.Layout.Appearance.BackColor = Color.White;

		// Hide the second band (band 1) when printing so rows from that band and its
		// descendant bands don't show up in the print.
		e.Layout.Bands[1].Hidden = true;
	}
	else
	{
		e.Layout.Appearance.BackColor = Color.Gray;
	}		

	// Set the behaviour of tab keys in the UltraGrid.
	this.ultraGrid1.DisplayLayout.TabNavigation = TabNavigation.NextCell;

}
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