C# 有没有办法让visual Studio上的计时器在某一点停止,而不是继续运行

C# 有没有办法让visual Studio上的计时器在某一点停止,而不是继续运行,c#,timer,visual-studio-2013,C#,Timer,Visual Studio 2013,基本上,我的意思是,当我按下一个按钮时,我想要一张图片移动,而要移动的图片在表单应用程序上的某个点移动,而不是取消它要移动的图片,然后在应用程序仍在运行的情况下停止。关于Microsoft visual Studio c#windows窗体应用程序 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using

基本上,我的意思是,当我按下一个按钮时,我想要一张图片移动,而要移动的图片在表单应用程序上的某个点移动,而不是取消它要移动的图片,然后在应用程序仍在运行的情况下停止。关于Microsoft visual Studio c#windows窗体应用程序

  using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;


        }
 private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    private void Form1_Load(object sender, EventArgs e)
        {

        }
 private void timer1_Tick(object sender, EventArgs e)
        {
            pictureBox1.Left += 2;
        }
    }
}

您可以调用
timer1.Stop()
停止计时器

您需要将
计时器的
Interval
属性设置为
raise
然后
ticketvent
Interval
设置一次

ticketvent
中,您可以
停止
计时器
或执行任何您想执行的操作

试试这个:

private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval=5000;//to raise tick event for 5 sec's
timer1.Start();
timer1.Tick += new System.EventHandler(this.timer1_Tick);
}

protected void timer1_Tick(Object sender,EventArgs e)
{    
//Stop the timer here
timer1.Stop();    
}

很好,但它们离计时器1太远了;再过几秒钟