Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 KnownColor Enumeration

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
KnownColor Enumeration

Specifies the known system colors.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Visual Basic (Declaration)
Public Enumeration KnownColor
Visual Basic (Usage)
Dim instance As KnownColor
C#
public enum KnownColor
Visual C++
public enum class KnownColor
JScript
public enum KnownColor
Member nameDescription
ActiveBorder The system-defined color of the active window's border.
ActiveCaption The system-defined color of the background of the active window's title bar.
ActiveCaptionText The system-defined color of the text in the active window's title bar.
AppWorkspace The system-defined color of the application workspace. The application workspace is the area in a multiple-document view that is not being occupied by documents.
Control The system-defined face color of a 3-D element.
ControlDark The system-defined shadow color of a 3-D element. The shadow color is applied to parts of a 3-D element that face away from the light source.
ControlDarkDark The system-defined color that is the dark shadow color of a 3-D element. The dark shadow color is applied to the parts of a 3-D element that are the darkest color.
ControlLight The system-defined color that is the light color of a 3-D element. The light color is applied to parts of a 3-D element that face the light source.
ControlLightLight The system-defined highlight color of a 3-D element. The highlight color is applied to the parts of a 3-D element that are the lightest color.
ControlText The system-defined color of text in a 3-D element.
Desktop The system-defined color of the desktop.
GrayText The system-defined color of dimmed text. Items in a list that are disabled are displayed in dimmed text.
Highlight The system-defined color of the background of selected items. This includes selected menu items as well as selected text.
HighlightText The system-defined color of the text of selected items.
HotTrack The system-defined color used to designate a hot-tracked item. Single-clicking a hot-tracked item executes the item.
InactiveBorder The system-defined color of an inactive window's border.
InactiveCaption The system-defined color of the background of an inactive window's title bar.
InactiveCaptionText The system-defined color of the text in an inactive window's title bar.
Info The system-defined color of the background of a ToolTip.
InfoText The system-defined color of the text of a ToolTip.
Menu The system-defined color of a menu's background.
MenuText The system-defined color of a menu's text.
ScrollBar The system-defined color of the background of a scroll bar.
Window The system-defined color of the background in the client area of a window.
WindowFrame The system-defined color of a window frame.
WindowText The system-defined color of the text in the client area of a window.
Transparent A system-defined color.
AliceBlue A system-defined color.
AntiqueWhite A system-defined color.
Aqua A system-defined color.
Aquamarine A system-defined color.
Azure A system-defined color.
Beige A system-defined color.
Bisque A system-defined color.
Black A system-defined color.
BlanchedAlmond A system-defined color.
Blue A system-defined color.
BlueViolet A system-defined color.
Brown A system-defined color.
BurlyWood A system-defined color.
CadetBlue A system-defined color.
Chartreuse A system-defined color.
Chocolate A system-defined color.
Coral A system-defined color.
CornflowerBlue A system-defined color.
Cornsilk A system-defined color.
Crimson A system-defined color.
Cyan A system-defined color.
DarkBlue A system-defined color.
DarkCyan A system-defined color.
DarkGoldenrod A system-defined color.
DarkGray A system-defined color.
DarkGreen A system-defined color.
DarkKhaki A system-defined color.
DarkMagenta A system-defined color.
DarkOliveGreen A system-defined color.
DarkOrange A system-defined color.
DarkOrchid A system-defined color.
DarkRed A system-defined color.
DarkSalmon A system-defined color.
DarkSeaGreen A system-defined color.
DarkSlateBlue A system-defined color.
DarkSlateGray A system-defined color.
DarkTurquoise A system-defined color.
DarkViolet A system-defined color.
DeepPink A system-defined color.
DeepSkyBlue A system-defined color.
DimGray A system-defined color.
DodgerBlue A system-defined color.
Firebrick A system-defined color.
FloralWhite A system-defined color.
ForestGreen A system-defined color.
Fuchsia A system-defined color.
Gainsboro A system-defined color.
GhostWhite A system-defined color.
Gold A system-defined color.
Goldenrod A system-defined color.
Gray A system-defined color.
Green A system-defined color.
GreenYellow A system-defined color.
Honeydew A system-defined color.
HotPink A system-defined color.
IndianRed A system-defined color.
Indigo A system-defined color.
Ivory A system-defined color.
Khaki A system-defined color.
Lavender A system-defined color.
LavenderBlush A system-defined color.
LawnGreen A system-defined color.
LemonChiffon A system-defined color.
LightBlue A system-defined color.
LightCoral A system-defined color.
LightCyan A system-defined color.
LightGoldenrodYellow A system-defined color.
LightGray A system-defined color.
LightGreen A system-defined color.
LightPink A system-defined color.
LightSalmon A system-defined color.
LightSeaGreen A system-defined color.
LightSkyBlue A system-defined color.
LightSlateGray A system-defined color.
LightSteelBlue A system-defined color.
LightYellow A system-defined color.
Lime A system-defined color.
LimeGreen A system-defined color.
Linen A system-defined color.
Magenta A system-defined color.
Maroon A system-defined color.
MediumAquamarine A system-defined color.
MediumBlue A system-defined color.
MediumOrchid A system-defined color.
MediumPurple A system-defined color.
MediumSeaGreen A system-defined color.
MediumSlateBlue A system-defined color.
MediumSpringGreen A system-defined color.
MediumTurquoise A system-defined color.
MediumVioletRed A system-defined color.
MidnightBlue A system-defined color.
MintCream A system-defined color.
MistyRose A system-defined color.
Moccasin A system-defined color.
NavajoWhite A system-defined color.
Navy A system-defined color.
OldLace A system-defined color.
Olive A system-defined color.
OliveDrab A system-defined color.
Orange A system-defined color.
OrangeRed A system-defined color.
Orchid A system-defined color.
PaleGoldenrod A system-defined color.
PaleGreen A system-defined color.
PaleTurquoise A system-defined color.
PaleVioletRed A system-defined color.
PapayaWhip A system-defined color.
PeachPuff A system-defined color.
Peru A system-defined color.
Pink A system-defined color.
Plum A system-defined color.
PowderBlue A system-defined color.
Purple A system-defined color.
Red A system-defined color.
RosyBrown A system-defined color.
RoyalBlue A system-defined color.
SaddleBrown A system-defined color.
Salmon A system-defined color.
SandyBrown A system-defined color.
SeaGreen A system-defined color.
SeaShell A system-defined color.
Sienna A system-defined color.
Silver A system-defined color.
SkyBlue A system-defined color.
SlateBlue A system-defined color.
SlateGray A system-defined color.
Snow A system-defined color.
SpringGreen A system-defined color.
SteelBlue A system-defined color.
Tan A system-defined color.
Teal A system-defined color.
Thistle A system-defined color.
Tomato A system-defined color.
Turquoise A system-defined color.
Violet A system-defined color.
Wheat A system-defined color.
White A system-defined color.
WhiteSmoke A system-defined color.
Yellow A system-defined color.
YellowGreen A system-defined color.
ButtonFace The system-defined face color of a 3-D element.
ButtonHighlight The system-defined color that is the highlight color of a 3-D element. This color is applied to parts of a 3-D element that face the light source.
ButtonShadow The system-defined color that is the shadow color of a 3-D element. This color is applied to parts of a 3-D element that face away from the light source.
GradientActiveCaption The system-defined color of the lightest color in the color gradient of an active window's title bar.
GradientInactiveCaption The system-defined color of the lightest color in the color gradient of an inactive window's title bar.
MenuBar The system-defined color of the background of a menu bar.
MenuHighlight The system-defined color used to highlight menu items when the menu appears as a flat menu.

The following code example demonstrates how to use the KnownColor enumeration to print out the names and colors of all its values. This example is designed to be used with Windows Forms. Create a form and paste the following code into it. Call the DisplayKnownColors method in the form's Paint event-handling method, passing e as PaintEventArgs.

Visual Basic
Private Sub DisplayKnownColors(ByVal e As PaintEventArgs)
    Me.Size = New Size(650, 550)
    Dim i As Integer

    ' Get all the values from the KnownColor enumeration.
    Dim colorsArray As System.Array = _
        [Enum].GetValues(GetType(KnownColor))
    Dim allColors(colorsArray.length) As KnownColor

    Array.Copy(colorsArray, allColors, colorsArray.Length)

    ' Loop through printing out the value's name in the colors 
    ' they represent.
    Dim y As Single
    Dim x As Single = 10.0F

    For i = 0 To allColors.Length - 1

        ' If x is a multiple of 30, start a new column.
        If (i > 0 And i Mod 30 = 0) Then
            x += 105.0F
            y = 15.0F
        Else
            ' Otherwise increment y by 15.
            y += 15.0F
        End If

        ' Create a custom brush from the color and use it to draw
        ' the brush's name.
        Dim aBrush As New SolidBrush(Color.FromName( _
            allColors(i).ToString()))
        e.Graphics.DrawString(allColors(i).ToString(), _
            Me.Font, aBrush, x, y)

        ' Dispose of the custom brush.
        aBrush.Dispose()
    Next

End Sub

C#
private void DisplayKnownColors(PaintEventArgs e)
{
    this.Size = new Size(650, 550);

    // Get all the values from the KnownColor enumeration.
    System.Array colorsArray = Enum.GetValues(typeof(KnownColor));
    KnownColor[] allColors = new KnownColor[colorsArray.Length];

    Array.Copy(colorsArray, allColors, colorsArray.Length);

    // Loop through printing out the values' names in the colors 
    // they represent.
    float y = 0;
    float x = 10.0F;

    for(int i = 0; i < allColors.Length; i++)
    {

        // If x is a multiple of 30, start a new column.
        if (i > 0 && i % 30 == 0)
        {
            x += 105.0F;
            y = 15.0F;
        }
        else
        {
            // Otherwise, increment y by 15.
            y += 15.0F;
        }

        // Create a custom brush from the color and use it to draw
        // the brush's name.
        SolidBrush aBrush = 
            new SolidBrush(Color.FromName(allColors[i].ToString()));
        e.Graphics.DrawString(allColors[i].ToString(), 
            this.Font, aBrush, x, y);

        // Dispose of the custom brush.
        aBrush.Dispose();
    }

}

Visual C++
private:
   void DisplayKnownColors( PaintEventArgs^ e )
   {
      this->Size = System::Drawing::Size( 650, 550 );

      // Get all the values from the KnownColor enumeration.
      System::Array^ colorsArray = Enum::GetValues( KnownColor::typeid );
      array<KnownColor>^allColors = gcnew array<KnownColor>(colorsArray->Length);
      Array::Copy( colorsArray, allColors, colorsArray->Length );

      // Loop through printing out the values' names in the colors 
      // they represent.
      float y = 0;
      float x = 10.0F;
      for ( int i = 0; i < allColors->Length; i++ )
      {
         // If x is a multiple of 30, start a new column.
         if ( i > 0 && i % 30 == 0 )
         {
            x += 105.0F;
            y = 15.0F;
         }
         else
         {
            // Otherwise, increment y by 15.
            y += 15.0F;
         }

         // Create a custom brush from the color and use it to draw
         // the brush's name.
         SolidBrush^ aBrush = gcnew SolidBrush( Color::FromName( allColors[ i ].ToString() ) );
         e->Graphics->DrawString( allColors[ i ].ToString(), this->Font, aBrush, x, y );

         // Dispose of the custom brush.
         delete aBrush;
      }
   }

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker