TextBox.DefaultBackColor (C#)

  • Thread starter Thread starter Mat Kramer
  • Start date Start date
M

Mat Kramer

Hi all,

I want to temporarily set the background color of a text box, so I use

my_text_box.BackColor = Color.BlanchedAlmond;

Then when I want to reset back to the default (white on my system), I
thought I could use

my_text_box.BackColor = TextBox.DefaultBackColor;

Unfortunately, this sets it to gray. Is this a bug or am I using it wrong?

Thanks

-Mat
 
The DefaultBackColor property is set to SystemColors.Control. Although I
don't know what that is set to on your system, I would imagine that would be
a grayish color. Try setting the BackColor to Color.Empty to reset the
BackColor to its true default.

--
Tim Wilson
..Net Compact Framework MVP

Mat Kramer said:
Hi all,

I want to temporarily set the background color of a text box, so I use

my_text_box.BackColor = Color.BlanchedAlmond;

Then when I want to reset back to the default (white on my system), I
thought I could use

my_text_box.BackColor = TextBox.DefaultBackColor;

Unfortunately, this sets it to gray. Is this a bug or am I using it wrong?

Thanks

-Mat
=----
 
The ResetBackColor method is hidden from the editor and I didn't want to
cause possible confusion by proposing this solution.
 
Back
Top