c# 清空窗体上所有控件内容

时间:2023-02-02 05:52:40


        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();
        }