for (j = 3; j > 0; j--)
                        {
                            
                            this.timerup.Start();
                            
                            
                        } private void timerup_Tick(object sender, EventArgs e)
        {                
                this.ElevatorStyleLeft.Location = new Point(ElevatorStyleLeft.Location.X, ElevatorStyleLeft.Location.Y - 80);
               
                    this.timerup.Stop();
               
            
        }为什么timer只执行了一次,怎样才能执行3次

解决方案 »

  1.   

    for (j = 3; j > 0; j--)
                            {
    this.ElevatorStyleLeft.Location = new }
      

  2.   

    吧this.timerup.Start();
    换成timerup_Tick(null,null);
      

  3.   

    for循环中直接执行 this.ElevatorStyleLeft.Location 这行代码
      

  4.   

    int count=0;
                    if(count>3)
    {
                    this.ElevatorStyleLeft.Location = new Point(ElevatorStyleLeft.Location.X, ElevatorStyleLeft.Location.Y - 80);
                   }else{
                        this.timerup.Stop();
                   }
      

  5.   

    private void timerup_Tick(object sender, EventArgs e)
            {                
                    this.ElevatorStyleLeft.Location = new Point(ElevatorStyleLeft.Location.X, ElevatorStyleLeft.Location.Y - 80);
                   
                        this.timerup.Stop();//执行计时器的Stop()方法后,计时器将停止工作。
                   
                
            }
      

  6.   

    设置timer.autoreset = true.
    不然你的timer执行一次以后就自动停止了。在你的事件处理函数里面计数,超过3次才调用timer.stop。其余时候不调用。
      

  7.   

    设置全局变量int i =0;  函数内每执行一次就i++在函数内用
    if(i>=3)
    {
    timer.Stop();
    }