我有这个LINE:
int Time = textBox1.Text;
一个ProgressBar
。我希望ProgressBar
加载特定时间 - 例如,20秒。我怎么能这样做?我经常搜索,但我无法弄清楚如何设置加载时间。
答案 0 :(得分:1)
private void Form1_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
timer1.Interval=1000;//1 second
timer1.Tick += new System.EventHandler(timer1_Tick);
timer1.Start();
progressBar1.Maximum = 20;
}
private void timer1_Tick(object sender, EventArgs e)
{
//do whatever you want
if(progressBar1.Value==progressBar1.Maximum)
timer1.Stop();
else
progressBar1.Value+=1;
}