protected void Clear(Control ctrl)
{
//ctrl.Text = "";
foreach (Control c in ctrl.Controls)
{
if (c is TextBox)
{
((TextBox)(c)).Text = "";
}
c.Text = "";
Clear(c);
}
}
private void button4_Click(object sender, EventArgs e)
{
Application.Restart();
}
本文介绍了如何使用C#编程语言来清除窗体上的所有控件内容,特别是TextBox。通过一个名为Clear的方法,遍历控件集合,针对TextBox类型设置其Text为空字符串,以此达到清空内容的效果。同时,文中还包含了一个button点击事件,用于重启应用程序。
787





