Version

Setting Cell Active and Selected Appearance

You can apply specific appearances for the active cell or row using the ActiveAppearance property on the UltraGridCell object. It is also possible to disable the cells from displaying the active (ActiveAppearance, ActiveCellAppearance, ActiveRowAppearance ) and selected(SelectedAppearance, SelectedCellAppearance and SelectedRowAppearance) state specific appearances, by setting the ActiveAppearancesEnabled and SelectedAppearancesEnabled properties exposed on the UltraGridOverride object to False.

The DefaultSelectedBackColor and DefaultSelectedForeColor properties of the UltraGridLayout object can be set to provide default colors for the BackColor and ForeColor of selected cells when the SelectedRowAppearance and SelectedAppearance properties have not been set. In order to prevent the WinGrid from displaying the default BackColor and ForeColor for selected cells, the DefaultSelectedBackColor and DefaultSelectedForeColor properties can be set to Color.Empty.

The following code assumes that you have an UltraGrid dropped onto your form. Also the control is bound to the Customers table of the Northwind database.

In Visual Basic:

' Sets the active cell's appearance
Me.ultraGrid1.Rows(5).Cells(3).ActiveAppearance.BackColor = Color.LightSeaGreen

In C#:

// Sets the active cell's appearance
this.ultraGrid1.Rows[5].Cells[3].ActiveAppearance.BackColor = Color.LightSeaGreen;
WinGrid Set Cell's Active and Selected Appearances 01.png

In Visual Basic:

' Disables any active appearance settings for the entire WinGrid
' this.ultraGrid1.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False

In C#:

// Disables any active appearance settings for the entire WinGrid
// this.ultraGrid1.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;

In Visual Basic:

' Sets the selected cell's appearance
Me.ultraGrid1.Rows(3).Cells(3).SelectedAppearance.BackColor = Color.Red

In C#:

// Sets the selected cell's appearance
this.ultraGrid1.Rows[03].Cells[3].SelectedAppearance.BackColor = Color.Red;
WinGrid Set Cell's Active and Selected Appearances 02.png

In Visual Basic:

' Disables any selected appearance settings for the entire WinGrid
'Me.ultraGrid1.DisplayLayout.Override.SelectedAppearancesEnabled = Infragistics.Win.DefaultableBoolean.[False]

In C#:

// Disables any selected appearance settings for the entire WinGrid
// this.ultraGrid1.DisplayLayout.Override.SelectedAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;

In Visual Basic:

' Displays default Back color and forecolor of selected cells
Me.ultraGrid1.DisplayLayout.DefaultSelectedBackColor = Color.LightSlateGray
Me.ultraGrid1.DisplayLayout.DefaultSelectedForeColor = Color.Blue

In C#:

// Displays default Back color and forecolor of selected cells
this.ultraGrid1.DisplayLayout.DefaultSelectedBackColor = Color.LightSlateGray;
this.ultraGrid1.DisplayLayout.DefaultSelectedForeColor = Color.Blue;
WinGrid Set Cell's Active and Selected Appearances 03.png