原来我的控件的Location是(8,490)。然后我想把它通过时间把它慢慢移动到(8,400)怎么办?
我想了一个办法:
protected void timer1_Tick(object sender, System.EventArgs e)
{
  double Time = 0.0 ;
  int Y = 490 ;

  while(Time<=3)
   {
Time += 0.01 ;
this.GroupBox.Location.Offset(8,Y);
Y -=10 ;
    }
}
然后再Form_Load()里timer1.Start();这样不行啊!

解决方案 »

  1.   

    protected void timer1_Tick(object sender, System.EventArgs e)
    {
      timer1.Enabled=false;
      while(GroupBox.Location.Y > 400)
       {
    this.GroupBox.Location.Offset(8,GroupBox.Location.Y);
    timer1.Interval=1000;
             timer1.Enable=true;
             timer1.Start();
        }

    }
      

  2.   

    具体代码你自己去测试。。思路是这样。。在Form_Load里设置timer1.Start()然后每触发一次tick判断控件是否到达位置,没有的话则移动8pixel,然后再启动timer,直到到达位置为止。。timer1的interval你可以自己控制,是控制移动的效果。while(GroupBox.Location.Y > 400)改为if(GroupBox.Location.Y > 400)应该就行了。。
      

  3.   

    好像Offset不能把GroupBox移动一样啊,,你给我那个第一个是一个死循环阿,你说第二个我也用了阿,就是不移动阿,气死我了
      

  4.   

    我以为你那句有用,我都没改。。this.GroupBox.Location.Offset(8,GroupBox.Location.Y);
    改为
    GroupBox.Location=new Point(GroupBox.Location.X,GroupBox.Location.Y-8);
      

  5.   

    private void Form1_Load(object sender, System.EventArgs e)
    {
         this.timer1.Start();
    }private void timer1_Tick(object sender, System.EventArgs e)
    {
    if ( this.GroupBox.Top < 481 )
        this.GroupBox.Top  += 10;
    else
        this.timer1.Stop();
    }
      

  6.   

    this.GroupBox.Location = new System.Drawing.Point(8,Y);
    换成这个试试
      

  7.   

    好,我给分了,Idda 谢谢你哈