Color.ToKnownColor Color.ToKnownColor Color.ToKnownColor Color.ToKnownColor Method


获取此 Color 结构的 KnownColor 值。Gets the KnownColor value of this Color structure.

 System::Drawing::KnownColor ToKnownColor();
public System.Drawing.KnownColor ToKnownColor ();
member this.ToKnownColor : unit -> System.Drawing.KnownColor
Public Function ToKnownColor () As KnownColor


如果 Color 是使用 FromName(String) 方法或 FromKnownColor(KnownColor) 方法基于预定义颜色创建的,则为 KnownColor 枚举的一个元素;否则为 0。An element of the KnownColor enumeration, if the Color is created from a predefined color by using either the FromName(String) method or the FromKnownColor(KnownColor) method; otherwise, 0.


预定义的颜色也称为已知的颜色,由的元素表示KnownColor枚举。A predefined color is also called a known color and is represented by an element of the KnownColor enumeration. ToKnownColor方法应用于Color通过使用创建结构FromArgb方法,ToKnownColor返回 0,即使与 ARGB 值匹配的预定义的颜色的 ARGB 值。When the ToKnownColor method is applied to a Color structure that is created by using the FromArgb method, ToKnownColor returns 0, even if the ARGB value matches the ARGB value of a predefined color. ToKnownColor 应用于时也会返回 0Color结构,它通过创建FromName方法不是有效的字符串名称。ToKnownColor also returns 0 when it is applied to a Color structure that is created by using the FromName method with a string name that is not valid.