C#的timer事件怎么用? 各位兄弟姐妹们,大家下午好。小妹我有个问题想请教大家,C#的timer事件怎么用? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Timer_Tick() 里面写到时间要做的事情Interval 属性设置间隔时间 拖拽上去 设置一下就行 其他的代码在Tick 里面this.timer1.Interval = 5000;//用于总计时this.timer1.Enabled = false;this.timer2.Interval = 1000;//用于刷新倒计时this.timer2.Enabled = false;//定义一个全局变量iprivate void button1_Click(object sender, EventArgs e) { this.timer1.Enabled = true; //单击button时开始计时 i = this.timer1.Interval; this.timer2.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { this.timer1.Enabled = false; //5秒后停止计时,并显示信息 MessageBox.Show("hello,baby"); } private void timer2_Tick(object sender, EventArgs e) { i-=1000; if (i <= 0) { this.timer2.Enabled = false; } label1.Text = (i/1000).ToString(); //每秒刷新倒计时 显示剩余时间 } http://msdn.microsoft.com/zh-cn/library/system.threading.timer.aspx 比如我有个控件 如果没有到选课的时间的话 我就会提示没有到选课的时间 如果到了选课的时间 就会出现选课的界面 我想用Timer怎么实现这个功能呢 private void Form1_Load(object sender, EventArgs e) { Timer timer = new Timer(); timer.Interval = 10000; timer.Tick += new EventHandler(timer_Tick); timer.Start(); } void timer_Tick(object sender, EventArgs e) { DateTime dt = DateTime.Now; if(dt.Equals("你要的时间")) { 。 } } timer.Interval = 1000;if里面置false。 就是,,,你的要实现的方法,放入到Timer的事件timer_Tick中去。。其余的看MSDN吧。 你总要自己做点事吧,别人代码都给你了你copy都懒得做? 网上多的去了 自己写也easy啊 VS 调试时输出窗口显示的异常 来着有分~~ 类。 程序放MP3的问题. C#.NET 多国语言版软件的开发需要注意哪些方面呢? 这个正则表达式很复杂吗?要怎么优化? 用c# 2005怎么做cs应用程序的启动封面呀?实现下有加载进度条,上面窗口又可以在程序加载时,浏览帮助画面... 运行耗时10秒左右的程序,实现提示用户“请稍等” 协议打包,解包的问题 socket IP地址变了,带来的问题!请教 C#中奇怪有趣的问题(有原代码)!各位高手请进! C#写的Com组件如何调用网页中的JS C#里面有没有和vb中的InStrRev一样功能的函数
设置一下就行 其他的代码在Tick 里面this.timer1.Interval = 5000;//用于总计时this.timer1.Enabled = false;this.timer2.Interval = 1000;//用于刷新倒计时this.timer2.Enabled = false;//定义一个全局变量iprivate void button1_Click(object sender, EventArgs e)
{
this.timer1.Enabled = true; //单击button时开始计时
i = this.timer1.Interval;
this.timer2.Enabled = true; } private void timer1_Tick(object sender, EventArgs e)
{
this.timer1.Enabled = false; //5秒后停止计时,并显示信息
MessageBox.Show("hello,baby");
} private void timer2_Tick(object sender, EventArgs e)
{
i-=1000;
if (i <= 0)
{
this.timer2.Enabled = false;
}
label1.Text = (i/1000).ToString(); //每秒刷新倒计时 显示剩余时间 }
{
Timer timer = new Timer();
timer.Interval = 10000;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
} void timer_Tick(object sender, EventArgs e)
{
DateTime dt = DateTime.Now; if(dt.Equals("你要的时间"))
{
。
}
}
其余的看MSDN吧。
你总要自己做点事吧,别人代码都给你了
你copy都懒得做?
自己写也easy啊