Color.IsKnownColor 属性


获取指示此 Color 结构是否为预定义颜色的值。Gets a value indicating whether this Color structure is a predefined color. 预定义颜色由 KnownColor 枚举的元素表示。Predefined colors are represented by the elements of the KnownColor enumeration.

 property bool IsKnownColor { bool get(); };
public bool IsKnownColor { get; }
member this.IsKnownColor : bool
Public ReadOnly Property IsKnownColor As Boolean


如果此 true 是使用 Color 方法或 FromName(String) 方法基于预定义颜色创建的,为 FromKnownColor(KnownColor);否则为 falsetrue if this Color was created from a predefined color by using either the FromName(String) method or the FromKnownColor(KnownColor) method; otherwise, false.


此属性不比较 ARGB 值。This property does not do a comparison of the ARGB values. 因此,当 IsKnownColor 属性应用到使用 FromArgb 方法创建的 Color 结构时,IsKnownColor 返回 false,即使 ARGB 值与预定义颜色的 ARGB 值匹配。Therefore, when the IsKnownColor property is applied to a Color structure that is created by using the FromArgb method, IsKnownColor returns false, even if the ARGB value matches the ARGB value of a predefined color.