关于展示时间
关于显示时间private void InitializeTimer(){// Call this procedure when the application starts.// Se
关于显示时间 private void InitializeTimer() { // Call this procedure when the application starts. // Set to 1 second. timer1.Interval = 1000; timer1.Tick += new EventHandler(timer1_Tick); // Enable timer. timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { label4.Text = System.DateTime.Now.ToString("H:M"); } 按我的设想应该是label4显示当前时间。 结果label4根本不变。 private void label4_Click(object sender, EventArgs e) { label4.Text = System.DateTime.Now.ToString("H:M"); } 我又写了这样一句,结果一点它就显示了。 求教哪里出问题了[最优解释] 1:楼主可以在Form窗体初始化的时候或者Form的构造函数里面调用InitializeTimer()方法 2:楼主完全也可以手动直接设置以下属性,VS会自动处理(Form2.Designer.cs)
this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick);[其他解释] timer1.Start() ???
[其他解释] 引用: timer1.Start() ??? timer1.Enabled = true;就实现这个功能了吧
[其他解释] 你在哪里调用InitializeTimer()了?
[其他解释] System.DateTime.Now.ToString("HH:mm:ss");
获取时间的问题你试试这个获取时间
[其他解释] 你在load时间中没有调用 InitializeTimer 这个方法设置time的属性,所以触发不了time的事件
[其他解释] 你在窗体的加载事件里面调用下你写的那个时间控件,可以简便一点:label4.Text = DateTime.Now()
在时间Tick事件里面每次加一秒就行了
[其他解释] 没有在正确的位置调用这个Timer_Tick的事件吧
[其他解释] 表示看不懂····白学这么多年计算机了
[其他解释] 虽然是路过,但是也从中学到了点东西。
[其他解释] 到Load加上timer1.Start()试试
引用: private void InitializeTimer() { // Call this procedure when the application starts. // Set to 1 second. timer1.Interval = 1000; timer1.Tic……
[其他解释] private void label4_Click(object sender, EventArgs e)
{
label4.Text = System.DateTime.Now.ToString("H:M");
}
还用得着这个????
[其他解释] 该回复于2012-12-07 08:52:23被管理员删除
[其他解释] 引用: System.DateTime.Now.ToString("HH:mm:ss"); 获取时间的问题你试试这个获取时间 我的获取时间语句没问题,你看我下边那一句就明白了
[其他解释] 引用: private void label4_Click(object sender, EventArgs e) { label4.Text = System.DateTime.Now.ToString("H:M"); } 还用得着这个???? 只是做个试验,看看我的获取时间与具有没有问题
[其他解释] 引用: 你在窗体的加载事件里面调用下你写的那个时间控件,可以简便一点:label4.Text = DateTime.Now() 在时间Tick事件里面每次加一秒就行了 我只要小时和分钟