VS2005 C# 中timer控件不执行
我用了VS2005,使用Winform,C#语言,我在窗口中想要显示系统时间,加了一个timer控件,设置好时间并使之生效。但程序运行后事件没有被触发。我跟踪了一些代码,...
我用了VS2005,使用Winform,C#语言,我在窗口中想要显示系统时间,加了一个timer控件,设置好时间并使之生效。但程序运行后事件没有被触发。我跟踪了一些代码,好像有一个绘制特别图形button的代码被反复执行,但timer始终没有被执行。 private void custombutton_Paint(object sender, PaintEventArgs e)
{
...
}这一段为重定义按钮形状,
private void timer2_Tick(object sender, EventArgs e)
{
timer2.Stop();
label1.Text = System.DateTime.Now.TimeOfDay.ToString();
timer2.Start();
}timer是这样,设置为500毫秒执行一次,
this.timer2.Enabled = true;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
我在网上搜了很多都没有找到原因。帮帮我,谢谢!急
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace dzhk
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.custombutton = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
...... 展开
{
...
}这一段为重定义按钮形状,
private void timer2_Tick(object sender, EventArgs e)
{
timer2.Stop();
label1.Text = System.DateTime.Now.TimeOfDay.ToString();
timer2.Start();
}timer是这样,设置为500毫秒执行一次,
this.timer2.Enabled = true;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
我在网上搜了很多都没有找到原因。帮帮我,谢谢!急
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace dzhk
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.custombutton = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
...... 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询