开发者

Using hexadecimal color code in System.Drawing.Color

开发者 https://www.devze.com 2023-02-10 14:51 出处:网络
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.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消