'Declaration Public Overloads Function Clone() As UltraGridLayout
public UltraGridLayout Clone()
Invoke this method to return a reference to a copy of an object. This is different from setting a variable equal to an object, which does not make a new copy.
This method is also useful when you want to base one object on another. For example, if you wanted one Appearance object to be the same as another, with the exception of several properties, you could clone the existing Appearance object, make changes to the copy, and use it to change an object's appearance.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private toggleFlag As Boolean = False Private layout1 As UltraGridLayout = Nothing Private layout2 As UltraGridLayout = Nothing Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button9.Click If Me.layout1 Is Nothing Or Me.layout2 Is Nothing Then Me.layout1 = Me.ultraGrid1.DisplayLayout ' Make a clone of layout1. Me.layout2 = layout1.Clone(PropertyCategories.All) ' Setup layout2. layout2.Override.CellAppearance.BackColor = Color.LightSkyBlue layout2.Bands(0).Columns(0).CellAppearance.BackColor = Color.Red End If ' Reset the layout since CopyFrom only copies properties that are set ' on the source layout. Me.ultraGrid1.DisplayLayout.Reset() If toggleFlag Then ' Copy the layout from layout1 Me.ultraGrid1.DisplayLayout.CopyFrom(layout1, PropertyCategories.All) Else ' Copy the layout from layout2 Me.ultraGrid1.DisplayLayout.CopyFrom(layout2, PropertyCategories.All) End If ' Toggle the flag. toggleFlag = Not toggleFlag End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private bool toggleFlag = false; private UltraGridLayout layout1 = null; private UltraGridLayout layout2 = null; private void button9_Click(object sender, System.EventArgs e) { if ( null == this.layout1 || null == this.layout2 ) { this.layout1 = this.ultraGrid1.DisplayLayout; // Make a clone of layout1. this.layout2 = layout1.Clone( PropertyCategories.All ); // Setup layout2. layout2.Override.CellAppearance.BackColor = Color.LightSkyBlue; layout2.Bands[0].Columns[0].CellAppearance.BackColor = Color.Red; } // Reset the layout since CopyFrom only copies properties that are set // on the source layout. this.ultraGrid1.DisplayLayout.Reset( ); if ( toggleFlag ) { // Copy the layout from layout1 this.ultraGrid1.DisplayLayout.CopyFrom( layout1, PropertyCategories.All ); } else { // Copy the layout from layout2 this.ultraGrid1.DisplayLayout.CopyFrom( layout2, PropertyCategories.All ); } // Toggle the flag. toggleFlag = !toggleFlag; }
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