首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么改变TextBox为只读,但不改变背景色

2012-01-31 
如何改变TextBox为只读,但不改变背景色?如何改变TextBox为只读,但不改变背景色?[解决办法]C# codeusing Sy

如何改变TextBox为只读,但不改变背景色?
如何改变TextBox为只读,但不改变背景色?

[解决办法]

C# code
using System;using System.Drawing;using System.Windows.Forms;class Test : Form{  Test()  {    TextBox TextBox1   = new TextBox();    TextBox1.Parent    = this;    TextBox1.Text      = "Click Me";    TextBox1.Click    += delegate    {      Color c = TextBox1.BackColor;      TextBox1.Text      = "ReadOnly";      TextBox1.ReadOnly  = true;      TextBox1.BackColor = c;    };  }  static void Main()  {    Application.Run(new Test());  }}
[解决办法]

this.TestBox1.ReadOnly=true;
this.TestBox1.BackColor=Color.white;
[解决办法]
//请再问下,在Enable=False的情况下,没办法改不改变字体颜色,我不想字体变成灰色

如果是这样的话,你试试使用TextBox1.ForeColor
1,readonly
2,backcolor | forecolor
如果不好使的话,再试试richTextBox吧,
[解决办法]
C# code
            textBox1.ReadOnly = true;            textBox1.ForeColor = Color.Black;            textBox1.BackColor = Color.White; 

热点排行