how to set backcolor for all textboxes in winform globally?
how to set backcolor for all textboxes in winform globally c#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Joginder BangerPosted Nov 26, 2014, 2:07 AM
{
public mycolor(coltrol ctr)
{
foreach (var control in ctr)
{
var box = control as TextBox;
if(box.text!=null && box.text!="")
{
box.BackColor = Color.Red;
}
}}
}
PrathapPosted Nov 26, 2014, 1:58 AM
Joginder BangerPosted Nov 26, 2014, 1:48 AM
add a new class in your code,call this class every pages.
public class mycolor
{
public mycolor(coltrol ctr)
{
foreach (var control in ctr)
{
var box = control as TextBox;
if (box != null)
box.BackColor = Color.Red;
}}
}
Munesh SharmaPosted Nov 26, 2014, 1:43 AM
public void colorchange()
{
Action<Control.ControlCollection> coll= null;
foreach (Control c in coll)
{
if (c is TextBox )
(control as TextBox).BackColor = Color.blue;
}
}
}
PrathapPosted Nov 26, 2014, 1:26 AM
Michal HabalcikPosted Nov 26, 2014, 1:11 AM
foreach (var control in this.Controls)
{
var box = control as TextBox;
if (box != null)
box.BackColor = Color.Red;
}