WinFrom 求个使用Timer控件的小例子 求个简单的Timer控件的小例子,我还不会用这个控件.想学下,随便什么例子,[C#] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 传说每天在CSDN吐口痰即可获得10分可用分! 简单来说拖个timer控件,设置下Interval属性,设置它的timer1_Tick事件。需要用的时候设置timer1.Enabled = true;就ok了。 private void Form1_Load(object sender, EventArgs e) { this.timer1.Enabled = true; this.timer1.Interval = 1000; //可以在属性中设置 } private void timer1_Tick(object sender, EventArgs e) { this.label1.Text = System.DateTime.Now.ToLongTimeString(); }你这口痰吐的真不小 是不是感冒了 显示当前时间的一个label时钟private void Time1_Tick(object sender, EventArgs e) { StatusLabel.Text = DateTime.Now.ToString(); } 显示当前时间的一个label时钟private void Time1_Tick(object sender, EventArgs e) { StatusLabel.Text = DateTime.Now.ToString(); } 那如果窗体上有个Button控件,可不可以做到这样:没隔1秒,让Button控件的位置向右移动100 private void timer1_Tick(object sender, EventArgs e) { //这个事件 如何写代码呢? } private void 调用方法() { timer1.Enabled = true; } this.timer1.Enabled = true;//可用状态this.timer1.Interval = 1000;//循环时间 毫秒this.timer1.Start();//开始执行this.timer1.Stop();//结束计时//循环事件private void timer1_Tick(object sender, EventArgs e){ this.label1.Text = System.DateTime.Now.ToLongTimeString();}在看看委托,随时定义timer和事件,更方便使用 this.timer1.Enabled = true; this.timer1.Interval = 1000;this.timer1.start(); button.Location = new Point(button.Location.X + 100, button.Location.Y); ! this.timer1.Enabled = true;//可用状态this.timer1.Interval = 1000;//循环时间 毫秒this.timer1.Start();//开始执行//this.timer1.Stop();//结束计时//循环事件private void timer1_Tick(object sender, EventArgs e){ this.button1.Location = new Point(button.Location.X + 100, button.Location.Y);} 用的时候time1.Start()就行不用了就timer1.Stop(); this.timer1.Enabled = true;//可用状态 this.timer1.Interval = 1000;//循环时间 毫秒 this.timer1.Start();//开始执行 //this.timer1.Stop();//结束计时 //循环事件 private void timer1_Tick(object sender, EventArgs e) { this.button1.Location = new Point(button.Location.X + 100, button.Location.Y); } MSDN上输入Timer查找Timer控件就看到了有实例的 private void timer1_Tick(object sender, EventArgs e) { this.button1.Left = this.button1.Left + 100; }真能折腾 回复你6楼 private void Form1_Load(object sender, EventArgs e) { timer1.Enabled = true; timer1.Interval = 1000; } private void timer1_Tick(object sender, EventArgs e) { button1.Location = new Point(button1.Location.X+10, button1.Location.Y); } 界面上拖个控件,用下面代码试试效果看看吧 private void ttm1_Tick(object sender, System.EventArgs e) { this.Opacity=this.Opacity+0.02; if(this.Opacity>0.98) { this.Opacity=1; ttm1.Stop(); } } timer控件用的不熟,只试过在一个label上根据timer值1000也就是一秒更新显示时间 D:\Backup\我的文档\My Pictures\4.jpg this.timer1.Enabled = true;this.timer1.Interval = 1000;//一秒钟执行一次在timer事件里面写:LB_TextTimer.Text = System.DateTime.Now.ToString(); 怎么在调试时跟踪代码 如何实现语音提示 用户控件 急,求解关于winfrom打印的问题?? C#发邮件的问题(如何隐藏真实的发信人地址) 关于.NET的forms认证问题 c#下面有什么好的Socket 框架? 高手帮我看看这段代码到底错在哪里?怎么总是跳出“未将对象引用设置到对象实例”? 小女子请教一个小问题好吗?(很不好意思,我只有10分) vs2013 wpf程序的udpsocket控件在哪里 PetShop数据库连接问题 visual studio 2005 字体设置
需要用的时候设置timer1.Enabled = true;就ok了。
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
//可以在属性中设置
} private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = System.DateTime.Now.ToLongTimeString();
}你这口痰吐的真不小 是不是感冒了
private void Time1_Tick(object sender, EventArgs e)
{ StatusLabel.Text = DateTime.Now.ToString();
}
private void Time1_Tick(object sender, EventArgs e)
{ StatusLabel.Text = DateTime.Now.ToString();
}
那如果窗体上有个Button控件,可不可以做到这样:
没隔1秒,让Button控件的位置向右移动100 private void timer1_Tick(object sender, EventArgs e)
{
//这个事件 如何写代码呢?
}
private void 调用方法()
{
timer1.Enabled = true;
}
this.timer1.Enabled = true;//可用状态
this.timer1.Interval = 1000;//循环时间 毫秒
this.timer1.Start();//开始执行
this.timer1.Stop();//结束计时//循环事件
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = System.DateTime.Now.ToLongTimeString();
}在看看委托,随时定义timer和事件,更方便使用
this.timer1.Interval = 1000;
this.timer1.start();
button.Location = new Point(button.Location.X + 100, button.Location.Y);
this.timer1.Enabled = true;//可用状态
this.timer1.Interval = 1000;//循环时间 毫秒
this.timer1.Start();//开始执行
//this.timer1.Stop();//结束计时//循环事件
private void timer1_Tick(object sender, EventArgs e)
{
this.button1.Location = new Point(button.Location.X + 100, button.Location.Y);
}
不用了就timer1.Stop();
this.timer1.Interval = 1000;//循环时间 毫秒
this.timer1.Start();//开始执行
//this.timer1.Stop();//结束计时 //循环事件
private void timer1_Tick(object sender, EventArgs e)
{
this.button1.Location = new Point(button.Location.X + 100, button.Location.Y);
}
有实例的
{
this.button1.Left = this.button1.Left + 100;
}真能折腾
回复你6楼
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 1000;
} private void timer1_Tick(object sender, EventArgs e)
{
button1.Location = new Point(button1.Location.X+10, button1.Location.Y);
}
{
this.Opacity=this.Opacity+0.02;
if(this.Opacity>0.98)
{
this.Opacity=1;
ttm1.Stop(); }
}
D:\Backup\我的文档\My Pictures\4.jpg
this.timer1.Interval = 1000;//一秒钟执行一次
在timer事件里面写:
LB_TextTimer.Text = System.DateTime.Now.ToString();