如何把字符串转换成Color类型
展开全部
1、Color.FromArgb(120,243,244,247)
先将F3,F4,F7转化为十进制数,再调用以上方法。
2、把F3 F4 F7转成10进制
然后用 Color.FromArgb
3、Color yourColor = Color.FromName("#F3F4F7");
4、比较笨一点的办法:
string a="#F3F4F7";
new System.Drawing.Color.fromArgb(
System.int8.parse(a.substring(1,2),System.Globalization.NumberStyles.AllowHexSpecifier);
System.int8.parse(a.substring(3,2),System.Globalization.NumberStyles.AllowHexSpecifier);
System.int8.parse(a.substring(5,2),System.Globalization.NumberStyles.AllowHexSpecifier);
);
5、Color color =Color.FromArgb(0xf3,0xf4,0xf7);
6、Public ForeColor As System.Drawing.Color = ColorTranslator.FromHtml("#F3F4F7")
7、System.Drawing.ColorConverter cc=new System.Drawing.ColorConverter();
return (System.Drawing.Color)cc.ConvertFromString(sHex)
先将F3,F4,F7转化为十进制数,再调用以上方法。
2、把F3 F4 F7转成10进制
然后用 Color.FromArgb
3、Color yourColor = Color.FromName("#F3F4F7");
4、比较笨一点的办法:
string a="#F3F4F7";
new System.Drawing.Color.fromArgb(
System.int8.parse(a.substring(1,2),System.Globalization.NumberStyles.AllowHexSpecifier);
System.int8.parse(a.substring(3,2),System.Globalization.NumberStyles.AllowHexSpecifier);
System.int8.parse(a.substring(5,2),System.Globalization.NumberStyles.AllowHexSpecifier);
);
5、Color color =Color.FromArgb(0xf3,0xf4,0xf7);
6、Public ForeColor As System.Drawing.Color = ColorTranslator.FromHtml("#F3F4F7")
7、System.Drawing.ColorConverter cc=new System.Drawing.ColorConverter();
return (System.Drawing.Color)cc.ConvertFromString(sHex)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询