如何在Timer控件的帮助下,让Label慢慢的移动到任意的坐标点.(比如鼠标点击的坐标点)

解决方案 »

  1.   

    应该找到你鼠标点击的坐标,然后再根据控件本身的坐标,按照你的意思(慢慢),计算出每次移动后的坐标,在TIMER中进行对控件位置的重新设置。
      

  2.   

    窗体有个MouseUp或用MouseDown
    在方法里:e.x,和e.y可以获得鼠标点击的坐标然后在一个timer事件里把label的location的x,y值一点一点的加到获取的坐标值最后在MouseUp或MouseDown里调用timer
      

  3.   

    用js做style的坐标,就可以移动
      

  4.   

    首先 MouseClike 方法 取得参数 MouseEvent e 的 e.X E.Y 就是坐标设定 Int mx,my 存储坐标在timer的计时动作中添加代码if(label.left<mx)
    {
      label.left+=1
    }
    else
    {
     label.left -= 1
    }
    if(label.top>my)
    {
     label.top-=1
    }
    else
    {
     label.top+=1
    }
      

  5.   

    主要的代码在这里
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    if(this.label1.Location.X<this.X)
    this.label1.Location = new System.Drawing.Point(this.label1.Location.X+1,this.label1.Location.Y);
    if(this.label1.Location.Y<this.Y)
    this.label1.Location = new System.Drawing.Point(this.label1.Location.X,this.label1.Location.Y+1);
    }private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    this.X = e.X;
    this.Y = e.Y;
    this.timer1.Start();
    }