Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset background color of textbox

I'm using VS2012 with VB.NET on a winforms application. I set the BackColor property of some textboxes programmatically during my code depending on form validation. This works fine, the problem is that I'd like to "reset" the BackColor property of the textbox, so that the textbox performs as if it were in the same state before I set the BackColor. So it would do the following:

Return to the default color of white immediately after "reset"

Change to that "light gray" color when the textbox.enabled = false

The reason why I cannot simply set the BackColor to Color.White, is that this affects the textbox when textbox.enabled = false. The textbox does not return that "light gray" color after setting the backcolor and disabling the textbox. I need it to return to that color, and I'd rather not have to set the textbox's color everytime I enable or disable the textbox. Thanks!

like image 677
jamesdlivesinatree Avatar asked Sep 06 '25 22:09

jamesdlivesinatree


1 Answers

Simply:

TextBox1.BackColor = SystemColors.Window
like image 128
SysDragon Avatar answered Sep 10 '25 21:09

SysDragon