来源:http://blog.csdn.net/xiong1000/archive/2006/12/12/1439927.aspx
================
类型"string"的值无法转换为"System.Drawing.Color"
代码如下:
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");  

相关文章:

  • 2022-12-23
  • 2021-11-06
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案