使用Timer控件和进度条
1.拖入progressBar控件和Timer控件
2.将timer控件属性Interval改为400,Enable属性改为false
并添加timer1_Tick()处理事件
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value >= 100)
{
progressBar1.Value = 0;
label1.Text = "进度" + progressBar1.Value.ToString() + "%";
return;
}
progressBar1.Value += 5;
label1.Text = "进度" + progressBar1.Value.ToString() + "%";
}
3.拖入2个button控件,分别将Text属性改为”开始“和“暂停”。
双击“开始”控件,添加
timer1.Enable=true;
双击“开始”控件,添加
timer1.Enable=false;
4.添加label控件,修改Text属性为“0%”