如何通过单击按钮刷新应用程序?

时间:2014-02-28 12:25:49

标签: c#

我只想问我的程序中有一个按钮,通过点击它会以动画的形式生成一些图像到我的输出屏幕。 我的问题是当我的表单打开并且程序正在执行时,每次我点击按钮它只是在彼此之上添加更多数据而不是重新运行程序。 你可以给我解决这个问题的任何解决方案吗?基本上当我点击按钮时它会从新的程序启动程序吗?

3 个答案:

答案 0 :(得分:1)

试试这段代码:

private void button1_Click(object sender, EventArgs e)
{
    this.Controls.Clear();
    InitializeComponent();
}

答案 1 :(得分:1)

试试这个:

private void button1_Click(object sender, EventArgs e)
{
    this.Controls.Clear();
    InitializeComponent();
    //the code you wrote in the button click or if the code is in another button write:
    // button.PerformClick();
}

答案 2 :(得分:0)

Control.Refresh Method

点击活动时刷新窗口。

相关问题