C#的TextBox控件的BackColor怎么赋值

this.TextBox1.BackColor = ??????????;我试过this.txtIDiograph.BackColor = ColorTranslator.ToHtml("#999999"); 报错,说:错误 1 与“System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color)”最匹配的重载方法具有一些无效参数错误 2 参数“1”: 无法从“string”转换为“System.Drawing.Color”

第1个回答  2011-10-20
额,如果是初始化的时候可以在控件属性那里直接选择颜色,如果是在程序运行时需要赋值或者改变则可以调用TextBox.BackColor =Color.XXX即可
第2个回答  推荐于2016-12-04
方法如下:
先把textbox1的访问修饰符改成public
再textbox1.text=(string)赋值的文本;
//from1.cs
public TextBox tb=new TextBox();
//new一个reader
//reader.cs
from1.tb.Text="加载完成";
第3个回答  2011-10-20
textBox1.BackColor = Color.Blue;
或者
textBox1.BackColor = System.Drawing.ColorTranslator.FromOle(000111);
自己改数值
textBox1.BackColor = System.Drawing.ColorTranslator.FromWin32(000222);
第4个回答  2011-10-20
在窗体设计器里赋值看看
form.Designer.cs
this.TextBox1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
第5个回答  推荐于2018-02-27
TextBox1.BackColor =System.Drawing.Color.Blue;
TextBox1.BackColor = “#999999”;本回答被提问者和网友采纳