C#中怎么用button键触发timer控件 代码是什么

类似照片查看器里的自动预览功能

timer.enabled = true 即可触发。自动预览功能,是利用timer控制的,你可以在timer中进行system.threading.thread.sleep(3000);来进行模拟操作即可
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-06-18
首先。Net有好几种timer,用在UI上的推荐System.Windows.Forms.Timer这个。
参考代码如下:

this.timer1 = this.timer1 = new System.Windows.Forms.Timer();
this.timer1.Interval = 2000;
this.timer1.Tick += new EventHandler(timer1_Tick);

void timer1_Tick(object sender, EventArgs e)
{
// 自动浏览code,每隔一定时间会自动触发这个函数。
}

private void button1_Click(object sender, EventArgs e)
{
this.timer1.Start();
}本回答被提问者采纳
第2个回答  2011-06-18
在button事件中写timer.Start();就可以了.照片查看器里的自动预览功能的代码写到timer的事件中就行.
相似回答