如何把字符串Color.Red 转化为 颜色的Color.Red???

解决方案 »

  1.   

    Type t = typeof(System.Drawing.Color);
    PropertyInfo[] propertys = t.GetProperties();foreach( PropertyInfo p in propertys)
    {
    if(p.Name == "Red")
    {
    this.BackColor = (Color)p.GetValue("red",null);
    }
    }
      

  2.   

    Color.FromName("Color.Red")
    不行的话就
    Color.FromName(“Red”)
      

  3.   

    hatita(悠远的风景) 你写的不错,我开始就没想到用反射,学了一招阿
      

  4.   

    string color = "red";
            TextBox1.ForeColor = System.Drawing.ColorTranslator.FromHtml(color);
            TextBox1.Text = "今天天气太热了!";