如何改变TextBox为只读,但不改变背景色?
如何改变TextBox为只读,但不改变背景色?
[解决办法]
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吧,
[解决办法]
textBox1.ReadOnly = true; textBox1.ForeColor = Color.Black; textBox1.BackColor = Color.White;