我有定時器3蜱事件內部i中TIMER3間隔設置爲的NumericUpDown值:如何根據numericupdown值實時更改計時器間隔?
private void timer3_Tick(object sender, EventArgs e)
{
try
{
Image iOLd = this.pictureBox1.Image;
Image img = Image.FromFile(_files[_indx].FullName);
trackBar1.Value = _indx;
label23.Text = _files[_indx].Name;
this.pictureBox1.Image = img;
if (iOLd != null)
iOLd.Dispose();
_indx++;
if (_indx >= _files.Count)
{
_indx = 0;
trackBar1.Value = 0;
}
timer3.Interval = Convert.ToInt32(numericUpDown1.Value);
}
catch
{
}
}
我也做了它在的NumericUpDown ValueChanged事件:
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
timer3.Interval = Convert.ToInt32(numericUpDown1.Value);
}
的問題是例如我設置numericupdown值,而程序運行到10000,它的移動速度非常慢,然後我立即將值設置爲1,因此,當我將其更改爲1時,timer3間隔生效,它等待另一個10000值的循環,然後timer3間隔正在作爲值1.
我想要做的是,當我將從1萬變爲1的數值下降時,它將立即改變,而不是等待另一輪10000值。
我看到答案的文本中有錯誤。這是一個Windows.Forms.Timer – Steve 2015-07-07 21:16:00