3
I have a method, which checks if a Textbox is filled, positive case follows normal, if it is blank, it displays a message on the screen, and paints Textbox background yellow, Here comes my doubt, how do I return to the default color?
At the moment, to return, I’m using:
public void limparCorBoxes(Control.ControlCollection controles)
{
//Faz um laço para todos os controles passados no parâmetro
foreach (Control ctrl in controles)
{
//Se o contorle for um TextBox...
if (ctrl is TextBox)
{
((TextBox)(ctrl)).BackColor = System.Drawing.Color.White;
}
}
}
However, this method brings me problems, because I have some Textbox that has the parameter ReadOnly = true
, that when used leaves the Textbox with the gray background color, and when I run the method above, all Textbox have the white background.
That’s right @Julio Borges, the use of system colors is always more appropriate, as long as you don’t need a specific color, because with the system colors the application will follow the color theme of the environment in which it is running. + 1
– Emerson JS
I certainly responded to enrich the content of your reply without editing it.
– Julio Borges
Julio and Emerson, Perfect. Thank you so much. I tested it here and it works perfectly. Thank you
– Thomas Erich Pimentel