62,073
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public int s=0;
public int m = 0;
public int h = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Interval = 1000;
timer1.Enabled = true;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
s++;
this.label1.Text = h.ToString()+":"+m.ToString()+":"+s.ToString();
if (s==60)
{
m += 1;
s = 0;
}
if (m==60)
{
h += 1;
m = 0;
}
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void button3_Click(object sender, EventArgs e)
{
timer1.Stop();
timer1.Enabled = false;
label1.Text = "0:0:0";
}
}
}