How can I disable a textbox without fading text?
2 answers
It would be better to have both Label
and TextBox
in the same place.
Hide TextBox
and show content in Label
until you're ready to edit it. Hide Label
and show at this point TextBox
.
Otherwise, you will have to subclass TextBox
and override the method OnPaint
, somewhat as follows:
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
}
Have a look at this answer and link.
+3
source to share