Version

Appearance Property (UltraGridCell)

Returns or sets the Appearance object that controls the object's formatting.
Syntax
'Declaration
 
Public Property Appearance As Infragistics.Win.Appearance
public Infragistics.Win.Appearance Appearance {get; set;}
Remarks

The Appearance property of an object is used to associate the object with an Appearance object that will determine its appearance. The Appearance object has properties that control settings such as color, borders, font, transparency, etc. For many of the objects in the UltraWinGrid, you do not set formatting properties directly. Instead, you set the properties of an Appearance object, which controls the formatting of the object it is attached to.

There are two ways of working with the Appearance property and assigning the attributes of an Appearance object to other objects. One way is to create a new Appearance object, adding it directly to the Appearances collection. Then you assign the new Appearance object to the Appearance property of the object you want to format. This method uses a "named" Appearance object that you must explicitly create (and to which you must assign property settings) before it can be used. For instance, you could create an object in the grid's Appearances collection and assign it some values as follows:

UltraWinGrid1.Appearances.Add "New1"

UltraWinGrid1.Appearances("New1").BorderColor = System.Drawing.Color.Blue

UltraWinGrid1.Appearances("New1").ForeColor = System.Drawing.Color.Red

Creating the object in this way does not apply formatting to any visible part of the grid. The object simply exists in the collection with its property values, waiting to be used. To actually use the object, you must assign it to the grid's (or another object's) Appearance property:

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

In this case, only one Appearance object exists. The grid's appearance is governed by the settings of the "New1" object in the collection. Any changes you make to the object in the collection will immediately be reflected in the grid.

The second way of working with the Appearance property is to use it to set property values directly, such as:

UltraWinGrid1.Appearance.ForeColor = System.Drawing.Color.Blue

In this case, an Appearance object is automatically created by the control. This Appearance object is not a member of an Appearances collection and it does not have a name. It is specific to the object for which it was created; it is an "intrinsic" Appearance object. Changes to the properties of an intrinsic Appearance object are reflected only in the object to which it is attached.

Note that you can assign properties from a named Appearance object to an intrinsic Appearance object without creating a dependency relationship. For example, the following code...

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

...does not establish a relationship between the foreground color of the intrinsic object and that of the named object. It is simply a one-time assignment of the named object's value to that of the intrinsic object. In this case, two Appearance objects exist - one in the collection and one attached to the grid - and they operate independently of one another.

If you wish to assign all the properties of a named object to an intrinsic object at once without creating a dependency relationship, you can use the Clone method of the Appearance object to duplicate its settings and apply them. So if you wanted to apply all the property settings of the named Appearance object "New1" to the grid's intrinsic Appearance object, but you did not want changes made to "New1" automatically reflected in the grid, you would use the following code:

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

Note that the properties of an Appearance object can also operate in a hierarchical fashion. Certain properties can be set to a "use default" value, which indicates to the control that the property should take its setting from the object's parent. This functionality is enabled by default, so that unless you specify otherwise, child objects resemble their parents, and formatting set at higher levels of the grid hierarchy is inherited by objects lower in the hierarchy.

Example
Following code sets CellAppearance on various objects in the UltraGrid. It illustrates how the resolution hierarchy works in the UltraGrid. Basically properties not set on an object get inherited from a higher level object. Highest level object is the Layout and its override. Then is the band and its override then is the column, row and cell in order.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button9.Click

      ' Get the layout, a band, a column, a row and a cell for the demonstration purpose.
      Dim layout As UltraGridLayout = Me.ultraGrid1.DisplayLayout
      Dim band As UltraGridBand = layout.Bands(0)
      Dim column As UltraGridColumn = band.Columns(0)
      Dim row As UltraGridRow = Me.ultraGrid1.Rows(0)
      Dim cell As UltraGridCell = row.Cells(column)

      ' The way the UltraGrid resolves cell appearance is that objects at a lower level
      ' in the object model hierarchy have higher precedence than objects in higher level.
      ' For example, a cell has a higher precedence than its row. A row has a higher
      ' precedence than a column. The precedence order usually is cell, row, column, band,
      ' layout in decresing precedence order.

      ' Set grid-wide cell appearance by using the layout's Override.
      layout.Override.CellAppearance.BackColor = Color.Yellow

      ' You can override above settings for a a band by setting the 
      ' Override.CellAppearance on the band. This will have higher precedence than
      ' the layout.Override.
      band.Override.CellAppearance.BackColor = Color.Magenta

      ' You can override cell appearance on a column as well so cell-appearance settings
      ' on both the band and the layout will be ignored.
      column.CellAppearance.BackColor = Color.Red

      ' In the same manner, you can override cell-apperance for a row.
      row.CellAppearance.BackColor = Color.Green

      ' You can override the cell-appearance for individual cells.
      cell.Appearance.BackColor = Color.Blue

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

private void button9_Click(object sender, System.EventArgs e)
{

	// Get the layout, a band, a column, a row and a cell for the demonstration purpose.
	UltraGridLayout layout = this.ultraGrid1.DisplayLayout;
	UltraGridBand   band   = layout.Bands[0];
	UltraGridColumn column = band.Columns[0];
	UltraGridRow    row    = this.ultraGrid1.Rows[0];
	UltraGridCell    cell   = row.Cells[column];

	// The way the UltraGrid resolves cell appearance is that objects at a lower level
	// in the object model hierarchy have higher precedence than objects in higher level.
	// For example, a cell has a higher precedence than its row. A row has a higher
	// precedence than a column. The precedence order usually is cell, row, column, band,
	// layout in decresing precedence order.

	// Set grid-wide cell appearance by using the layout's Override.
	layout.Override.CellAppearance.BackColor = Color.Yellow;

	// You can override above settings for a a band by setting the 
	// Override.CellAppearance on the band. This will have higher precedence than
	// the layout.Override.
	band.Override.CellAppearance.BackColor = Color.Magenta;

	// You can override cell appearance on a column as well so cell-appearance settings
	// on both the band and the layout will be ignored.
	column.CellAppearance.BackColor = Color.Red;

	// In the same manner, you can override cell-apperance for a row.
	row.CellAppearance.BackColor = Color.Green;

	// You can override the cell-appearance for individual cells.
	cell.Appearance.BackColor = Color.Blue;

}
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