This documentation is archived and is not being maintained.

Color.Name Property

Gets the name of this Color.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public string Name { get; }
/** @property */
public String get_Name ()

public function get Name () : String

Not applicable.

Property Value

The name of this Color.

This method returns either the user-defined name of the color, if the color was created from a name, or the name of the known color. For custom colors, the RGB value is returned.

The following code example demonstrates how to use the Name property. This example is designed to be used with Windows Forms. Paste the code into a form that contains a button named Button2 and associate the Button2_Click method with the button's Click event.

private void Button2_Click(System.Object sender, System.EventArgs e)

    Button2.Width = 100;
    Button2.Text = "Color: "+Button2.BackColor.Name;

private void button2_Click(Object sender, System.EventArgs e)
    button2.set_Text("Color: " + button2.get_BackColor().get_Name());
} //button2_Click

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0