我想根据值下拉列表中选定的值启动代码,我还想指定一个time range (下面的示例)。我想要触发的代码在button1_Click后面,所以我想通过代码单击它。
//Create the timer
Timer timer = new Timer();
//set it up
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = (1000 * 60 * 5);
timer.Enabled = true;
timer.Start();
//now do stuff
void timer_Tick(object sender, EventArgs e)
{
//click the button using code
}假设我从下拉列表中选择了8,这意味着我想点击我的按钮8次,然而,该按钮需要按同样的时间范围。
所以让我说我选择:
::13:00
To:15:00
给我三个小时的时间。然后,我想把我从下拉列表中选择的数字除以(如8小时/分钟)。
在这个例子中,我希望每22.5分钟点击一次按钮。
发布于 2014-01-04 14:58:33
在SelectedValueChanged上,重置计时器。停止它,重置间隔,然后重新启动它。在事件处理程序中,执行click方法。
https://stackoverflow.com/questions/20922412
复制相似问题