一分钟计时器的制作方法(简单秒表计时器的制作)(1)

计时器 开始 停止 重置 功能的设计

这个简单计时器的功能如下:


using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Exercise { public partial class 计时器 : Form { private DateTime timeSum; public 计时器() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.timeSum = new DateTime(0); //开始显示时间 0.0.0:0 this.label1.Text = timeSum.Hour "." timeSum.Minute "." timeSum.Second ":" timeSum.Millisecond; this.button2.Enabled = false; } private void IncreaseTime(double seconds) { this.timeSum = this.timeSum.AddSeconds(seconds); this.label1.Text = timeSum.Hour "." timeSum.Minute "." timeSum.Second ":" timeSum.Millisecond; } private void timer1_Tick(object sender, EventArgs e) { this.IncreaseTime(0.1); } private void button1_Click(object sender, EventArgs e) { this.timer1.Start(); this.button1.Enabled = false; this.button2.Enabled = true; } private void button2_Click(object sender, EventArgs e) { this.timer1.Stop(); this.button1.Enabled = true; this.button2.Enabled = false; } private void button3_Click(object sender, EventArgs e) { this.timeSum = new DateTime(0); //开始显示时间 0.0.0:0 this.timer1.Stop(); this.label1.Text = timeSum.Hour "." timeSum.Minute "." timeSum.Second ":" timeSum.Millisecond; this.button1.Enabled = true; this.button2.Enabled = true; } } }

,