作者chrisQQ (ChrisLiu)
看板C_Sharp
標題Re: [問題] 如何讓label 不受timer變化?
時間Fri Dec 11 23:45:44 2009
> 滑鼠移開後, 上頭的數字會從 00:00:31:5 繼續跑
> 想請教各位這功能應該怎麼加入? 謝謝
我用個偷懶的方法…
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 Form1()
{
InitializeComponent();
}
int ms, sec, min, hr;
+ boon stopDisplay = false;
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void button1_MouseEnter(object sender, EventArgs e)
{
+ this.stopDisplay = true;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
+ this.stopDisplay = false;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
Ms.Text = "00";
Sec.Text = "00";
Min.Text = "00";
Hr.Text = "00";
}
private void timer1_Tick(object sender, EventArgs e)
{
ms++;
Ms.Text = ms.ToString();
if (ms > 9)
{
ms = 0;
! if (!stopDisplay) Ms.Text = ms.ToString();
sec++;
! if (!stopDisplay) Sec.Text = sec.ToString();
if (sec > 59)
{
sec = 0;
! if (!stopDisplay) Sec.Text = sec.ToString();
min++;
! if (!stopDisplay) Min.Text = min.ToString();
if (min > 59)
{
min = 0;
! if (!stopDisplay) Min.Text = min.ToString();
hr++;
! if (!stopDisplay) Hr.Text = hr.ToString();
}
}
}
}
}
}
→ LAGURA77:沒實做 希望能幫到你@@ 12/08 22:01
我也沒實做ˇˇ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.145.202.66
推 LAGURA77:這個方法好像比較簡潔@@ 原po應該參考這個 12/12 19:55