这是我写的,但是我无法在开始按钮中控制时间的走动,麻烦前辈帮忙解决一下,谢谢!
long second = 360;
//时钟控件
private void Changetimer_Tick(object sender, EventArgs e)
{
second -= 1;
lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();
//进度条根据时间的变化而变化
if (prggessbar.Value >= 360)
{
Changetimer.Enabled = false;
//..关闭或开启程序
}
else
{
prggessbar.Value += 1;
}
}
//结束按钮
private void btnEndTime_Click(object sender, EventArgs e)
{
//如何正在计时,则先停止再清零,否则直接清零
//if (this.Changetimer.Enabled == true)
//{
long second = 360;
lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();
prggessbar.Value = 0;//设置当前值
Changetimer.Enabled = false;
//}
}
//开始按钮
private void btnBeginTime_Click(object sender, EventArgs e)
{
if (this.Changetimer.Enabled == true)
{
Changetimer.Enabled = true;
//进度条的加载
prggessbar.Minimum = 0;
prggessbar.Maximum = 360;
prggessbar.Step = 1;
}
else
{
Changetimer.Enabled = false;
Changetimer.Interval = 1000;//一秒中加载一次
Changetimer.Tick += new EventHandler(this.Changetimer_Tick);
}
}
long second = 360;
//时钟控件
private void Changetimer_Tick(object sender, EventArgs e)
{
second -= 1;
lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();
//进度条根据时间的变化而变化
if (prggessbar.Value >= 360)
{
Changetimer.Enabled = false;
//..关闭或开启程序
}
else
{
prggessbar.Value += 1;
}
}
//结束按钮
private void btnEndTime_Click(object sender, EventArgs e)
{
//如何正在计时,则先停止再清零,否则直接清零
//if (this.Changetimer.Enabled == true)
//{
long second = 360;
lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();
prggessbar.Value = 0;//设置当前值
Changetimer.Enabled = false;
//}
}
//开始按钮
private void btnBeginTime_Click(object sender, EventArgs e)
{
if (this.Changetimer.Enabled == true)
{
Changetimer.Enabled = true;
//进度条的加载
prggessbar.Minimum = 0;
prggessbar.Maximum = 360;
prggessbar.Step = 1;
}
else
{
Changetimer.Enabled = false;
Changetimer.Interval = 1000;//一秒中加载一次
Changetimer.Tick += new EventHandler(this.Changetimer_Tick);
}
}