SystemColors Class (System.Drawing)

Switch View :
ScriptFree
.NET Framework Class Library
SystemColors Class

Each property of the SystemColors class is a Color structure that is the color of a Windows display element.

Inheritance Hierarchy

System.Object
  System.Drawing.SystemColors

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Syntax

Visual Basic
Public NotInheritable Class SystemColors
C#
public sealed class SystemColors
Visual C++
public ref class SystemColors sealed
F#
[<Sealed>]
type SystemColors =  class end

The SystemColors type exposes the following members.

Properties

  Name Description
Public property Static member ActiveBorder Gets a Color structure that is the color of the active window's border.
Public property Static member ActiveCaption Gets a Color structure that is the color of the background of the active window's title bar.
Public property Static member ActiveCaptionText Gets a Color structure that is the color of the text in the active window's title bar.
Public property Static member AppWorkspace Gets a Color structure that is the color of the application workspace.
Public property Static member ButtonFace Gets a Color structure that is the face color of a 3-D element.
Public property Static member ButtonHighlight Gets a Color structure that is the highlight color of a 3-D element.
Public property Static member ButtonShadow Gets a Color structure that is the shadow color of a 3-D element.
Public property Static member Control Gets a Color structure that is the face color of a 3-D element.
Public property Static member ControlDark Gets a Color structure that is the shadow color of a 3-D element.
Public property Static member ControlDarkDark Gets a Color structure that is the dark shadow color of a 3-D element.
Public property Static member ControlLight Gets a Color structure that is the light color of a 3-D element.
Public property Static member ControlLightLight Gets a Color structure that is the highlight color of a 3-D element.
Public property Static member ControlText Gets a Color structure that is the color of text in a 3-D element.
Public property Static member Desktop Gets a Color structure that is the color of the desktop.
Public property Static member GradientActiveCaption Gets a Color structure that is the lightest color in the color gradient of an active window's title bar.
Public property Static member GradientInactiveCaption Gets a Color structure that is the lightest color in the color gradient of an inactive window's title bar.
Public property Static member GrayText Gets a Color structure that is the color of dimmed text.
Public property Static member Highlight Gets a Color structure that is the color of the background of selected items.
Public property Static member HighlightText Gets a Color structure that is the color of the text of selected items.
Public property Static member HotTrack Gets a Color structure that is the color used to designate a hot-tracked item.
Public property Static member InactiveBorder Gets a Color structure that is the color of an inactive window's border.
Public property Static member InactiveCaption Gets a Color structure that is the color of the background of an inactive window's title bar.
Public property Static member InactiveCaptionText Gets a Color structure that is the color of the text in an inactive window's title bar.
Public property Static member Info Gets a Color structure that is the color of the background of a ToolTip.
Public property Static member InfoText Gets a Color structure that is the color of the text of a ToolTip.
Public property Static member Menu Gets a Color structure that is the color of a menu's background.
Public property Static member MenuBar Gets a Color structure that is the color of the background of a menu bar.
Public property Static member MenuHighlight Gets a Color structure that is the color used to highlight menu items when the menu appears as a flat menu.
Public property Static member MenuText Gets a Color structure that is the color of a menu's text.
Public property Static member ScrollBar Gets a Color structure that is the color of the background of a scroll bar.
Public property Static member Window Gets a Color structure that is the color of the background in the client area of a window.
Public property Static member WindowFrame Gets a Color structure that is the color of a window frame.
Public property Static member WindowText Gets a Color structure that is the color of the text in the client area of a window.
Top
Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Remarks

Better performance is achieved by using the properties of the SystemPens or SystemBrushes classes rather than creating a new pen or brush based on a value from SystemColors. For example, if you wanted to get a brush for the face color of a 3-D element, use the SystemBrushes.Control property because it gets a brush that already exists, whereas calling the SolidBrush constructor with a parameter value of SystemColors.Control will create a new brush.

Examples

The following code example demonstrates the Equality operator and the SystemColors class. This example is designed to be used with a Windows Form that contains a button named Button1. Paste the following code into your form and associate the Button1_Click method with the button's Click event.

Visual Basic

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    If (Color.op_Equality(Me.BackColor, SystemColors.ControlDark)) Then
        Me.BackColor = SystemColors.Control
    End If
End Sub


C#

private void Button1_Click(System.Object sender, System.EventArgs e)
{

    if (this.BackColor == SystemColors.ControlDark)
    {
        this.BackColor = SystemColors.Control;
    }
}


Visual C++

void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( this->BackColor == SystemColors::ControlDark )
   {
      this->BackColor = SystemColors::Control;
   }
}


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Reference