Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using hexadecimal color code in System.Drawing.Color

Is there a way to specify the hexadecimal code(something like #E9E9E9) while setting the color of a datagrid instead of using the below code.

dg.BackColor = System.Drawing.Color.LightGray
like image 694
Manasa Avatar asked Feb 16 '11 08:02

Manasa


People also ask

How do you use hexadecimal color codes?

Hex color codes start with a pound sign or hashtag (#) and are followed by six letters and/or numbers. The first two letters/numbers refer to red, the next two refer to green, and the last two refer to blue. The color values are defined in values between 00 and FF (instead of from 0 to 255 in RGB).

What is the hexadecimal color code system?

A hex color code is a 6-symbol code made of up to three 2-symbol elements. Each of the 2-symbol elements expresses a color value from 0 to 255. The code is written using a formula that turns each value into a unique 2-digit alphanumeric code. For example, the RGB code (224, 105, 16) is E06910 in hexadecimal code.

How does the 6 digit hexadecimal color system work?

In a six-digit hexadecimal notation, the digits pairwise indicate the red, green, and blue component in the RGB system. For example, #0000FF has 0 for red, 0 for green, and FF (which is 15 × 16 + 15 = 255 in decimal), i.e. the maximum, for blue (in the meaning it has in RGB).

Which number system is used to represent the color codes?

Color Numbers. Color numbers are specified using hexadecimal (base 16) values. The six digit color number is broken into three groups of two digits which specify the amount of Red, Green, and Blue in the color (using additive color...the way colored lights mix, not the way color pigments mix).


1 Answers

dg.BackColor =  System.Drawing.ColorTranslator.FromHtml("#E9E9E9");
like image 149
Moo-Juice Avatar answered Sep 20 '22 14:09

Moo-Juice