Click to See Complete Forum and Search --> : Hex value to color name


murugesun
03-16-2009, 08:15 AM
Hai Everyone,
How to get the color name from hexadecimal value? please suggest me...

cridley
03-25-2009, 08:28 AM
In c#:


string rgb = "#ffffff";
string Name = rgb;
ColorConverter cc = new ColorConverter();
Color c = (Color)cc.ConvertFromString(rgb);
if (c.IsNamedColor)
Name = c.Name;


The string name should now hold the value "White"

JoeyD
03-29-2009, 09:42 PM
I use this for databinding backcolors but you can use it anywhere


protected System.Drawing.Color setButtonColor(object HexCode)
{
return System.Drawing.Color.FromName(HexCode.ToString());
}

OR:

System.Drawing.Color divBackColor = System.Drawing.Color.FromName("#ffffff");