Back to Devexpress

AppearanceObject.BackColor Property

windowsforms-devexpress-dot-utils-dot-appearanceobject-f3f24940.md

latest7.3 KB
Original Source

AppearanceObject.BackColor Property

Gets or sets the background color.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
[XtraSerializableProperty]
[DXCategory("Appearance")]
public Color BackColor { get; set; }
vb
<XtraSerializableProperty>
<DXCategory("Appearance")>
Public Property BackColor As Color

Property Value

TypeDescription
Color

The background color.

|

Remarks

If the AppearanceOptions.UseBackColor property is set to false and the appearance object has a parent, the parent’s background color is used. Use the AppearanceObject.GetBackColor method to obtain the background color specified by the appearance object’s settings.

When an AppearanceObject’s style setting (for example, BackColor , ForeColor , Font and TextOptions.HAlignment ) is set to a non-default value, the corresponding Options.Use… option (for instance, Options.UseBackColor , Options.UseForeColor , Options.UseFont and Options.UseTextOptions ) is automatically set to true in the following cases:

  • The AppearanceObject belongs to a control/component (or its element), and this control/component has been completely loaded (see the control’s IsLoading property to check the load status);
  • The AppearanceObject belongs to a grid column/band or tree list column/band, and the column/band belongs to a grid/tree list control;
  • The AppearanceObject is standalone, that is, it does not belong to any control or component.

In other cases, the Options.Use… options are not automatically enabled. You may need to enable these options manually for the style settings to be in effect.

The following code snippets (auto-collected from DevExpress Examples) contain references to the BackColor property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-scheduler-country-specific-work-week-holidays/CS/Form1.cs#L110

csharp
cell.Appearance.ForeColor = Color.DarkGoldenrod;
cell.Appearance.BackColor = Color.PaleGreen;
break;

winforms-save-restore-splitter-position/CS/UserControl1.cs#L72

csharp
//
this.splitContainerControl1.Panel1.Appearance.BackColor = System.Drawing.Color.Lime;
this.splitContainerControl1.Panel1.Appearance.Options.UseBackColor = true;

winforms-treelist-implement-group-level-style-feature/CS/Q220534/Form1.cs#L30

csharp
if (e.Node.ParentNode == null) {
    Pen linePen = e.Cache.GetPen(tree.ViewInfo.PaintAppearance.HorzLine.BackColor);
    e.Cache.DrawLine(linePen, e.Bounds.Location, new Point(e.Bounds.Right, e.Bounds.Y));

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/GanttItem/GanttItemControlProvider.cs#L78

csharp
int colorData = (int)flatData.GetValue(flatData.GetColoringColumn().Name, row);
    e.Appearance.BackColor = Color.FromArgb(colorData);
}

winforms-grid-print-custom-draw-content/CS/MyXtraGrid/Form1.cs#L35

csharp
e.Handled = true;
e.Appearance.BackColor = Color.Yellow;
e.Appearance.FillRectangle(e.Cache, e.Bounds);

winforms-scheduler-country-specific-work-week-holidays/VB/Form1.vb#L101

vb
cell.Appearance.ForeColor = Color.DarkGoldenrod
    cell.Appearance.BackColor = Color.PaleGreen
' Highlight selection.

winforms-save-restore-splitter-position/VB/UserControl1.vb#L72

vb
'
splitContainerControl1.Panel1.Appearance.BackColor = System.Drawing.Color.Lime
splitContainerControl1.Panel1.Appearance.Options.UseBackColor = True

winforms-treelist-implement-group-level-style-feature/VB/Q220534/Form1.vb#L29

vb
If e.Node.ParentNode Is Nothing Then
    Dim linePen As Pen = e.Cache.GetPen(tree.ViewInfo.PaintAppearance.HorzLine.BackColor)
    e.Cache.DrawLine(linePen, e.Bounds.Location, New Point(e.Bounds.Right, e.Bounds.Y))

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/GanttItem/GanttItemControlProvider.vb#L74

vb
Dim colorData As Integer = DirectCast(flatData.GetValue(flatData.GetColoringColumn().Name, row), Integer)
    e.Appearance.BackColor = Color.FromArgb(colorData)
End Sub

winforms-grid-print-custom-draw-content/VB/MyXtraGrid/Form1.vb#L35

vb
e.Handled = True
e.Appearance.BackColor = Color.Yellow
e.Appearance.FillRectangle(e.Cache, e.Bounds)

See Also

UseBackColor

ParentAppearance

GetBackColor

AppearanceObject Class

AppearanceObject Members

DevExpress.Utils Namespace