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
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).
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.
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).
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).
dg.BackColor = System.Drawing.ColorTranslator.FromHtml("#E9E9E9");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With