This documentation is archived and is not being maintained.

Color.ToKnownColor Method

Gets the KnownColor value of this Color structure.

[Visual Basic]
Public Function ToKnownColor() As KnownColor
[C#]
public KnownColor ToKnownColor();
[C++]
public: KnownColor ToKnownColor();
[JScript]
public function ToKnownColor() : KnownColor;

Return Value

An element of the KnownColor enumeration, if the Color structure is created from a pre-defined color by using either the FromName method or the FromKnownColor method; otherwise, zero.

Remarks

A pre-defined color is also called a known color and is represented by an element of the KnownColor enumeration. When the ToKnownColor method is applied to a Color structure that is created by using the FromArgb method, the ToKnownColor method returns zero, even if the ARGB value matches the ARGB value of a pre-defined color. The ToKnownColor method also returns zero when it is applied to a Color structure that is created by using the FromName method with an invalid string name.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Color Structure | Color Members | System.Drawing Namespace

Show: