进度条到期时更改表单的背景图像

我正在尝试创建一个程序,一旦“假”进度条到期,表单的背景图像将更改为另一个。 这是我第一次使用表单作为GUI,所以我真的很感激帮助。 如果可能,请解释代码的工作原理。 我正在使用Visual Studio 2017.这是代码的样子。

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Form_Application { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { this.progressBar1.Increment(1); } } } 

在这种情况下,您必须检查进度条值是否为100,它将是:

 private void timer1_Tick(object sender, EventArgs e) { if(progressBar1.Value<100) // set progressBar max value to 100 { // if the value smaller than 100, will increment. this.progressBar1.Increment(1); } else{ timer1.Stop(); // Important to stop the timer // here you change the background image of the form. this.BackgroundImage = // choose ur image location. } }