Export (0) Print
Expand All

KnownColor Enumeration

Specifies the known system colors.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public enum KnownColor
public enum KnownColor
public enum KnownColor

 Member nameDescription
ActiveBorderThe system-defined color of the active window's border. 
ActiveCaptionThe system-defined color of the background of the active window's title bar. 
ActiveCaptionTextThe system-defined color of the text in the active window's title bar. 
AliceBlueA system-defined color. 
AntiqueWhiteA system-defined color. 
AppWorkspaceThe 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. 
AquaA system-defined color. 
AquamarineA system-defined color. 
AzureA system-defined color. 
BeigeA system-defined color. 
BisqueA system-defined color. 
BlackA system-defined color. 
BlanchedAlmondA system-defined color. 
BlueA system-defined color. 
BlueVioletA system-defined color. 
BrownA system-defined color. 
BurlyWoodA system-defined color. 
ButtonFaceThe system-defined face color of a 3-D element. 
ButtonHighlightThe 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. 
ButtonShadowThe 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. 
CadetBlueA system-defined color. 
ChartreuseA system-defined color. 
ChocolateA system-defined color. 
ControlThe system-defined face color of a 3-D element. 
ControlDarkThe 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. 
ControlDarkDarkThe 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. 
ControlLightThe 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. 
ControlLightLightThe 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. 
ControlTextThe system-defined color of text in a 3-D element. 
CoralA system-defined color. 
CornflowerBlueA system-defined color. 
CornsilkA system-defined color. 
CrimsonA system-defined color. 
CyanA system-defined color. 
DarkBlueA system-defined color. 
DarkCyanA system-defined color. 
DarkGoldenrodA system-defined color. 
DarkGrayA system-defined color. 
DarkGreenA system-defined color. 
DarkKhakiA system-defined color. 
DarkMagentaA system-defined color. 
DarkOliveGreenA system-defined color. 
DarkOrangeA system-defined color. 
DarkOrchidA system-defined color. 
DarkRedA system-defined color. 
DarkSalmonA system-defined color. 
DarkSeaGreenA system-defined color. 
DarkSlateBlueA system-defined color. 
DarkSlateGrayA system-defined color. 
DarkTurquoiseA system-defined color. 
DarkVioletA system-defined color. 
DeepPinkA system-defined color. 
DeepSkyBlueA system-defined color. 
DesktopThe system-defined color of the desktop. 
DimGrayA system-defined color. 
DodgerBlueA system-defined color. 
FirebrickA system-defined color. 
FloralWhiteA system-defined color. 
ForestGreenA system-defined color. 
FuchsiaA system-defined color. 
GainsboroA system-defined color. 
GhostWhiteA system-defined color. 
GoldA system-defined color. 
GoldenrodA system-defined color. 
GradientActiveCaptionThe system-defined color of the lightest color in the color gradient of an active window's title bar. 
GradientInactiveCaptionThe system-defined color of the lightest color in the color gradient of an inactive window's title bar.  
GrayA system-defined color. 
GrayTextThe system-defined color of dimmed text. Items in a list that are disabled are displayed in dimmed text. 
GreenA system-defined color. 
GreenYellowA system-defined color. 
HighlightThe system-defined color of the background of selected items. This includes selected menu items as well as selected text.  
HighlightTextThe system-defined color of the text of selected items. 
HoneydewA system-defined color. 
HotPinkA system-defined color. 
HotTrackThe system-defined color used to designate a hot-tracked item. Single-clicking a hot-tracked item executes the item. 
InactiveBorderThe system-defined color of an inactive window's border. 
InactiveCaptionThe system-defined color of the background of an inactive window's title bar. 
InactiveCaptionTextThe system-defined color of the text in an inactive window's title bar. 
IndianRedA system-defined color. 
IndigoA system-defined color. 
InfoThe system-defined color of the background of a ToolTip. 
InfoTextThe system-defined color of the text of a ToolTip. 
IvoryA system-defined color. 
KhakiA system-defined color. 
LavenderA system-defined color. 
LavenderBlushA system-defined color. 
LawnGreenA system-defined color. 
LemonChiffonA system-defined color. 
LightBlueA system-defined color. 
LightCoralA system-defined color. 
LightCyanA system-defined color. 
LightGoldenrodYellowA system-defined color. 
LightGrayA system-defined color. 
LightGreenA system-defined color. 
LightPinkA system-defined color. 
LightSalmonA system-defined color. 
LightSeaGreenA system-defined color. 
LightSkyBlueA system-defined color. 
LightSlateGrayA system-defined color. 
LightSteelBlueA system-defined color. 
LightYellowA system-defined color. 
LimeA system-defined color. 
LimeGreenA system-defined color. 
LinenA system-defined color. 
MagentaA system-defined color. 
MaroonA system-defined color. 
MediumAquamarineA system-defined color. 
MediumBlueA system-defined color. 
MediumOrchidA system-defined color. 
MediumPurpleA system-defined color. 
MediumSeaGreenA system-defined color. 
MediumSlateBlueA system-defined color. 
MediumSpringGreenA system-defined color. 
MediumTurquoiseA system-defined color. 
MediumVioletRedA system-defined color. 
MenuThe system-defined color of a menu's background. 
MenuBarThe system-defined color of the background of a menu bar. 
MenuHighlightThe system-defined color used to highlight menu items when the menu appears as a flat menu. 
MenuTextThe system-defined color of a menu's text. 
MidnightBlueA system-defined color. 
MintCreamA system-defined color. 
MistyRoseA system-defined color. 
MoccasinA system-defined color. 
NavajoWhiteA system-defined color. 
NavyA system-defined color. 
OldLaceA system-defined color. 
OliveA system-defined color. 
OliveDrabA system-defined color. 
OrangeA system-defined color. 
OrangeRedA system-defined color. 
OrchidA system-defined color. 
PaleGoldenrodA system-defined color. 
PaleGreenA system-defined color. 
PaleTurquoiseA system-defined color. 
PaleVioletRedA system-defined color. 
PapayaWhipA system-defined color. 
PeachPuffA system-defined color. 
PeruA system-defined color. 
PinkA system-defined color. 
PlumA system-defined color. 
PowderBlueA system-defined color. 
PurpleA system-defined color. 
RedA system-defined color. 
RosyBrownA system-defined color. 
RoyalBlueA system-defined color. 
SaddleBrownA system-defined color. 
SalmonA system-defined color. 
SandyBrownA system-defined color. 
ScrollBarThe system-defined color of the background of a scroll bar. 
SeaGreenA system-defined color. 
SeaShellA system-defined color. 
SiennaA system-defined color. 
SilverA system-defined color. 
SkyBlueA system-defined color. 
SlateBlueA system-defined color. 
SlateGrayA system-defined color. 
SnowA system-defined color. 
SpringGreenA system-defined color. 
SteelBlueA system-defined color. 
TanA system-defined color. 
TealA system-defined color. 
ThistleA system-defined color. 
TomatoA system-defined color. 
TransparentA system-defined color. 
TurquoiseA system-defined color. 
VioletA system-defined color. 
WheatA system-defined color. 
WhiteA system-defined color. 
WhiteSmokeA system-defined color. 
WindowThe system-defined color of the background in the client area of a window. 
WindowFrameThe system-defined color of a window frame. 
WindowTextThe system-defined color of the text in the client area of a window. 
YellowA system-defined color. 
YellowGreenA system-defined color. 

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.

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();
    }

}

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

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

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

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

    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;
            y = 15;
        }
        else {
            // Otherwise, increment y by 15.
            y += 15;
        }

        // Create a custom brush from the color and use it to draw
        // the brush's name.
        SolidBrush aBrush = new SolidBrush(Color.FromName(
            allColors.get_Item(i).ToString()));

        e.get_Graphics().DrawString(allColors.get_Item(i).ToString(),
            this.get_Font(), aBrush, x, y);

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

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft