首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# timer定时触发Button事件,该如何处理

2012-04-13 
C# timer定时触发Button事件如题,想请求一点思路。想定时在1小时触发一次。[解决办法]C# codeprivate void b

C# timer定时触发Button事件
如题,想请求一点思路。
想定时在1小时触发一次。

[解决办法]

C# code
        private void button1_Click(object sender, EventArgs e)        {        }        private void timer1_Tick(object sender, EventArgs e)        {            button1_Click(button1, null);        }
[解决办法]
载入窗口的时候
设个变量T=当前时间
打开定时器并设定周期一秒,并使定时器工作。
 private void button1_Click(object sender, EventArgs e)
{


}

private void timer1_Tick(object sender, EventArgs e)
{
设个变量T1=当前时间
如果T1与T差整好一小时
{
T1=T

button1_Click(button1, null);
}
}

没写代码,觉得是这个思路

热点排行