ColorDialog.CustomColors 属性

获取或设置对话框中显示的自定义颜色集。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property CustomColors As Integer()
用法
Dim instance As ColorDialog
Dim value As Integer()

value = instance.CustomColors

instance.CustomColors = value
public int[] CustomColors { get; set; }
public:
property array<int>^ CustomColors {
    array<int>^ get ();
    void set (array<int>^ value);
}
/** @property */
public int[] get_CustomColors ()

/** @property */
public void set_CustomColors (int[] value)
public function get CustomColors () : int[]

public function set CustomColors (value : int[])

属性值

对话框显示的自定义颜色集。默认值为 空引用(在 Visual Basic 中为 Nothing)。

备注

用户可创建自己的自定义颜色集。这些颜色包含在一个由 ARGB 组件(alpha、红、绿和蓝)值(这些组件值是创建颜色所必需的)所组成的 Int32 中。有关该数据的结构的更多信息,请参见 Color

只有当 AllowFullOpen 设置为 true 时,才可以定义自定义颜色。

示例

下面的代码示例演示如何将表示自定义颜色的 Int32 类型数组添加到 CustomColors 之中。该示例要求从 Form 中运行代码。

Dim MyDialog = New ColorDialog()
' Allows the user to select or edit a custom color.
MyDialog.AllowFullOpen = True
' Assigns an array of custom colors to the CustomColors property.
MyDialog.CustomColors = New Integer() {6916092, 15195440, 16107657, 1836924, _
   3758726, 12566463, 7526079, 7405793, 6945974, 241502, 2296476, 5130294, _
   3102017, 7324121, 14993507, 11730944}

' Allows the user to get help. (The default is false.)
MyDialog.ShowHelp = True
' Sets the initial color select to the current text color,
' so that if the user cancels out, the original color is restored.
MyDialog.Color = Me.BackColor
MyDialog.ShowDialog()
Me.BackColor = MyDialog.Color
System.Windows.Forms.ColorDialog MyDialog = new ColorDialog();
// Allows the user to select or edit a custom color.
MyDialog.AllowFullOpen = true ;
// Assigns an array of custom colors to the CustomColors property
MyDialog.CustomColors = new int[]{6916092, 15195440, 16107657, 1836924,
   3758726, 12566463, 7526079, 7405793, 6945974, 241502, 2296476, 5130294,
   3102017, 7324121, 14993507, 11730944,};

// Allows the user to get help. (The default is false.)
MyDialog.ShowHelp = true ;
// Sets the initial color select to the current text color,
// so that if the user cancels out, the original color is restored.
MyDialog.Color = this.BackColor;
MyDialog.ShowDialog();
this.BackColor =  MyDialog.Color;
System::Windows::Forms::ColorDialog^ MyDialog = gcnew ColorDialog;

// Allows the user to select or edit a custom color.
MyDialog->AllowFullOpen = true;

// Assigns an array of custom colors to the CustomColors property
array<int>^temp0 = {6916092,15195440,16107657,1836924,3758726,12566463,7526079,7405793,6945974,241502,2296476,5130294,3102017,7324121,14993507,11730944};
MyDialog->CustomColors = temp0;

// Allows the user to get help. (The default is false.)
MyDialog->ShowHelp = true;

// Sets the initial color select to the current text color,
// so that if the user cancels out, the original color is restored.
MyDialog->Color = this->BackColor;
MyDialog->ShowDialog();
this->BackColor = MyDialog->Color;
System.Windows.Forms.ColorDialog myDialog = new ColorDialog();
// Allows the user to select or edit a custom color.
myDialog.set_AllowFullOpen(true);
// Assigns an array of custom colors to the CustomColors property
myDialog.set_CustomColors(new int[] { 6916092, 15195440, 16107657, 
    1836924, 3758726, 12566463, 7526079, 7405793, 6945974, 241502, 
    2296476, 5130294, 3102017, 7324121, 14993507, 11730944 });
// Allows the user to get help. (The default is false.)
myDialog.set_ShowHelp(true);
// Sets the initial color select to the current text color,
// so that if the user cancels out, the original color is restored.
myDialog.set_Color(this.get_BackColor());
myDialog.ShowDialog();
this.set_BackColor(myDialog.get_Color());

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ColorDialog 类
ColorDialog 成员
System.Windows.Forms 命名空间
ColorDialog.AnyColor 属性