当我的计时器达到秒数(10、20 或 30)时,我希望出现一个消息框。这可行,但不是只有 1 个消息框,而是出现了 9 个!我不知道为什么?
private void timer1_Tick(object sender, EventArgs e)
{
int hrs = sw.Elapsed.Hours, mins = sw.Elapsed.Minutes, secs = sw.Elapsed.Seconds;
label5.Text = "";
if (mins < 60)
label5.Text += "0" + mins + ":";
else
label5.Text += mins + ":";
if(secs < 60)
label5.Text += secs;
else if(secs < 60)
label5.Text += secs;
if (comboBox1.Text == "10 seconden") // maximale tijd per beurt instellen.
if (mins == 00 && secs == 10)
MessageBox.Show("Je tijd is op!");
if (comboBox1.Text == "20 seconden")
if (mins == 00 && secs == 20)
MessageBox.Show("Je tijd is op");
if (comboBox1.Text == "30 seconden")
if (mins == 00 && secs == 30)
MessageBox.Show("Je tijd is op");