如何在不淡化文本的情况下禁用文本框?

How to disable a textbox without fading text?

有没有办法获取 !enabled textbox 除了褪色文本的所有属性?

我不能使用 Label,因为我希望 textbox 最终成为 enabled。我不能使用 readonly 因为我不希望用户的光标出现在其中。

最好在同一位置同时放置 LabelTextBox

隐藏 TextBox 并显示 Label 中的内容,直到您准备好对其进行编辑。 此时,隐藏 Label 并显示 TextBox.

否则,您必须子类化 TextBox,并重写 OnPaint 方法,有点像下面这样:

protected override void OnPaint(PaintEventArgs e)
{
     SolidBrush drawBrush = new SolidBrush(ForeColor); //Use the ForeColor property
     // Draw string to screen.
     e.Graphics.DrawString(Text, Font, drawBrush, 0f,0f); //Use the Font property
}

看看这个answer and this link

使用 SystemColor 而不是 KnownColor:

Color color = textbox1.BackColor ;
textbox1.BackColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);

color = textbox1.ForeColor ;
textbox1.ForeColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);