Freigeben über


ColorDialog.CustomColors-Eigenschaft

Ruft den im Dialogfeld angezeigten Satz benutzerdefinierter Farben ab oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property CustomColors As Integer()
'Usage
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[])

Eigenschaftenwert

Ein Satz benutzerdefinierter Farben, die im Dialogfeld angezeigt werden. Der Standardwert ist NULL (Nothing in Visual Basic).

Hinweise

Benutzer können einen eigenen Satz benutzerdefinierter Farben erstellen. Diese Farben sind in einer Instanz von Int32 enthalten, die aus den Werten der ARGB-Komponenten (Alpha, rot, grün und blau) besteht, die zum Erstellen der Farbe erforderlich sind. Weitere Informationen zur Struktur dieser Daten finden Sie unter Color.

Benutzerdefinierte Farben können nur definiert werden, wenn AllowFullOpen auf true festgelegt ist.

Beispiel

Das folgende Codebeispiel veranschaulicht, wie CustomColors ein Array vom Typ Int32 hinzugefügt werden kann, das benutzerdefinierte Farben darstellt. Für dieses Beispiel ist es erforderlich, dass der Code aus einem Form aufgerufen wird.

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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ColorDialog-Klasse
ColorDialog-Member
System.Windows.Forms-Namespace
ColorDialog.AnyColor-Eigenschaft