public partial class Form1 : Form
{
TimeSpan ts = new TimeSpan(0, 0, 60);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Visible = false;
timer1.Interval = 1000;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = ts.Hours.ToString() + ":" + ts.Minutes.ToString() + ":" + ts.Seconds.ToString();
label1.Visible = true;
ts = ts.Subtract(new TimeSpan(0, 0, 1));
if (ts.TotalSeconds<0.0)
{
timer1.Enabled = false;
label1.Visible = false;
MessageBox.Show("考試時間到,系統將強行交卷");
}
}
}