作用:进度条,用于展示某个任务的完成情况,
常用属性:
设定进度条的最大、最小值、自增步长
常用事件:
后台代码:
private void progressBar1_Click(object sender, EventArgs e){Thread t;//使用线程执行耗时任务,同时把进度以进度条的方式展示出来t = new Thread(() =>{while (progressBar1.Value != progressBar1.Maximum){this.Invoke(new Action(() =>{progressBar1.Value += 10;//在进度条控件上面放置一个label控件,展示进度条的实时值label2.Text = progressBar1.Value.ToString();}));Thread.Sleep(1000);}this.Invoke(new Action(() =>{label2.Text = "任务完成!!";}));});t.IsBackground = true;t.Start();}