清空Text的方法

在Form窗体的按钮写

 Class1 clear = new Class1();
   clear.clearText(this);

新建一个类

public void clearText(Form from)
        {
            foreach (Control c in from.Controls)
            {
                if (c is TextBox)
                {
                    c.Text = "";
                }
                if (c is ComboBox)
                {
                    c.Text = "";
                }
            }
        }

以后要用直接调用就行yes

发布了67 篇原创文章 · 获赞 72 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_42957931/article/details/89763361