winform c# 60秒计时器的程序
答案:2 悬赏:30
解决时间 2021-03-24 13:13
- 提问者网友:冰点阿弟
- 2021-03-23 15:53
winform c# 60秒计时器的程序
最佳答案
- 二级知识专家网友:一池湖水
- 2021-03-23 16:38
直接使用Timer控件
设置timer1.Interval=60000 //执行频率为60秒
private void timer_Tick(object sender, System.EventArgs e){
timer1.Enabled=false; //停止记时
//这里是执行语句
}
设置timer1.Interval=60000 //执行频率为60秒
private void timer_Tick(object sender, System.EventArgs e){
timer1.Enabled=false; //停止记时
//这里是执行语句
}
全部回答
- 1楼网友:花一样艳美的陌生人
- 2021-03-23 17:48
private int totalsecond = 299;
private int tenthsecond = 9;
private void timer1_tick(object sender, eventargs e)
{
//---窗体添加一个label,一个button,一个timer--------
//---5分钟倒计时,---功能单一,还有其他需求可以提。
int minute = totalsecond / 60;
int second = totalsecond % 60;
string str = minute.tostring() + ":" + second.tostring() + ":" + tenthsecond.tostring();
label1.text = str;
tenthsecond--;
if (tenthsecond == -1)
{
tenthsecond = 9;
totalsecond--;
if (totalsecond == -1)
{
timer1.enabled = false;
timer3.enabled = false;
label1.text = "时间到!";
label1.forecolor = color.fromargb(255, 0, 0);
}
}
}
private void button1_click(object sender, eventargs e)
{
timer1.enabled = true;
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯