16进制字符串转为数字
左直拳
Conver.ToInt32(“0xAB”,16);
所以在代码里给控件赋颜色值,可以这样:
public string ForeColor
{
set
{
//value = #ab364f
int r = Convert.ToInt32("0x" + value.Substring(1, 2),16);
int g = Convert.ToInt32("0x" + value.Substring(3, 2),16);
int b = Convert.ToInt32("0x" + value.Substring(5, 2),16);
txtUrl.ForeColor = System.Drawing.Color.FromArgb(r,g,b);
}
}