本文介绍了如何在Timer_tick()事件中触发Button_Click()事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在.net Windows Form应用程序项目中的Timer_Tick()
事件旁边触发Button_Click()
事件?
这样,将根据设置的时间间隔连续执行Button_Click()
中编写的代码.
How to fire Button_Click()
event in side the Timer_Tick()
event in .net windows form application project?
So that what are codes written in Button_Click()
will be executed continuously according time interval set.
推荐答案
private void timer1_Tick(object sender, EventArgs e)
{
button1.PerformClick();
}
或:
or:
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click(button1, null);
}
private void button1_Click(object sender, EventArgs e)
{
}
或(这是首选解决方案):
or (this is the preferred solution):
private void timer1_Tick(object sender, EventArgs e)
{
MyMethod();
}
private void button1_Click(object sender, EventArgs e)
{
MyMethod();
}
private void MyMethod()
{
}
这篇关于如何在Timer_tick()事件中触发Button_Click()事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!