با این کد میتونید برای بعضی از کنترل های روی فرمتون خاصیتی رو اعمال کنید
public void SetProperty(params Control[] SA)
{
foreach (Control ct in SA)
ct.Text = "softafzar.net";
}
private void button1_Click(object sender, EventArgs e)
{
SetProperty(button2, button3, button4);
}
اگر بخوایداین کار رو روی همه کنترل های روی یه Container اعمال کنید، از این کد استفاده کیند:
public void ClearControls(Control _parent)
{
if (!_parent.HasChildren)
_parent.Text = "";
foreach (Control ct in _parent.Controls)
ClearControls(ct);
}
private void button1_Click(object sender, EventArgs e)
{
ClearControls(this);
}