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