如何改变TextBox为只读,但不改变背景色?
解决方案 »
- 用代码的方式编译项目,资源文件的嵌入问题
- lock问题
- 关于DataList递归 急 高分
- 求助,关于Z4M打印机用C#写程序时每次打印10个条码程序就会死掉,各位高手帮忙看看,手上没分,有分时给大家补上
- dataGridView显示删除成功了,但是数据库里面数据还在
- C#打开图片问题.....
- COLORREF在.NET中是什么啊?
- 请问在如何先弹出个小窗口输入帐号、口令,正确后登陆到另一界面?解决就结帖,在线等……
- C#如何在打开主界面的同时打开登陆界面
- 多线程 主线程挂掉的问题,万分感谢
- 在TextBox.Enable=False的时,不想字体变成灰色,怎么办?
- 如何让DataGridView的列变成combobox
using System.Drawing;
using System.Windows.Forms;class Test : Form
{
Test()
{
TextBox TextBox1 = new TextBox();
TextBox1.Parent = this;
TextBox1.ReadOnly = true;
TextBox1.BackColor = Color.White;
} static void Main()
{
Application.Run(new Test());
}
}
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());
}
}
如果还想不改变背景颜色,那就再设置BackColor吧
this.TestBox1.ReadOnly=true;
this.TestBox1.BackColor=Color.white;
1,readonly
2,backcolor | forecolor
如果不好使的话,再试试richTextBox吧,
textBox1.ForeColor = Color.Black;
textBox1.BackColor = Color.White;测试过了,放对位置就可以!
楼上的,我的意思是说,参考空军的代码,再加上一条ForeColor就是楼主的第二个问题的答案了
参看八楼问
//请再问下,在Enable=False的情况下,没办法改不改变字体颜色,我不想字体变成灰色