类型"string"的值无法转换为"System.Drawing.Color"

2014-11-24 02:57:41 · 作者: · 浏览: 1

代码如下:
string strC="#C0FFFF";
Label1.BackColor=strC;

报错为:类型"string"的值无法转换为"System.Drawing.Color"

解决方法一:
string strC="#C0FFFF";
Label1.BackColor=System.Drawing.ColorTranslator.FromHtml(strC)

解决方法二:
string strC= "#C0FFFF";
Label1.BackColor=System.Drawing.Color.FromName("#C0FFFF");

作者“离殇、”