除了褪色文本之外,是否有办法获取 !enabled
textbox
的所有属性?
我不能使用 Label
,因为我希望 textbox
最终被启用
。我不能使用 readonly
,因为我不希望用户的光标出现在其中。
最佳答案
最好将 Label
和 TextBox
放在同一位置。
隐藏 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
}
关于c# - 如何在不淡化文本的情况下禁用文本框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31811525/