Using hexadecimal color code in System.Drawing.Color
Is there a way to specify the hexadecimal code(something like #E9E9E9) while setting the co开发者_运维问答lor of a datagrid instead of using the below code.
dg.BackColor = System.Drawing.Color.LightGray
dg.BackColor = System.Drawing.ColorTranslator.FromHtml("#E9E9E9");
try this :
dg.BackColor = Sytem.Drawing.Color.FromArgb(0, 0xE9, 0xE9, 0xE9);
or
string myColor = "#E9E9E9";
dg.BackColor = Sytem.Drawing.Color.FromArgb(int.Parse(myColor.Replace("#", "0x"));
Yes.
Color.FromArgb:
dg.BackColor = Color.FromArgb(0xE9, 0xE9, 0xE9);
Close:
Color.FromArgb(0, 0xe9, 0xe9, 0xe9);
精彩评论