Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

03/07/13

Using a Hexadecimal color instead of a System.Drawing.Color - Nannette Thacker ShiningStar.net

Nannette Thacker ShiningStar.net


ASP.net Web Application Development

Using a Hexadecimal color instead of a System.Drawing.Color


A colleague asked me how to use a hexademical color on an object that requires a System.Drawing.Color. It's quite simple and I thought I'd share it. As an example, you may define a background color using the System.Drawing.Color: panRow.BackColor = Drawing.Color.Red But you want a custom color, so you may instead use the ColorTranslator and define the Hex value: panRow.BackColor = System.Drawing.ColorTranslator.FromHtml("#FF5B5B") This is true of all controls that require a System.Drawing.Color. May your dreams be in ASP.NET! Nannette

Posted: Aug 18 2010, 03:30 PM by nannette | with 3 comment(s) Filed under: ASP.NET Comments CS-Son said:
or alte rnative ly: panR ow.Back C olor = Syste m .Drawing.C olor.From Argb(0x FF, 0x 5B, 0x 5B); ;)

# A ugus t 1 9 , 2 0 1 0 6 :0 7 A M

RichardD said:
O r e ve n: panR ow.Back C olor = Syste m .Drawing.C olor.From Argb(0x FF5B5B);

# A ugus t 1 9 , 2 0 1 0 7 :3 2 A M

weblogs.asp.net/nannettethacker/archive/2010/08/18/using-a-hexadecimal-color-instead-of-a-system-drawing-color.aspx

1/2

03/07/13

Using a Hexadecimal color instead of a System.Drawing.Color - Nannette Thacker ShiningStar.net

Terms of Use

weblogs.asp.net/nannettethacker/archive/2010/08/18/using-a-hexadecimal-color-instead-of-a-system-drawing-color.aspx

2/2

You might also like