title: C# - Moving a control to the mouse's position
body: <p>I am trying to get a control to follow the cursor when the user clicks and drag the control. The problem is that 1.) the control doesn't go to the mouse's position, and 2.) the control flickers and flies all over the place. I've tried a few different methods of doing this, but all so far have failed.</p>
  
  <p>I've tried:</p>
  
  <pre><code>protected override void OnMouseDown(MouseEventArgs e)
  {
       while (e.Button == System.Windows.Forms.MouseButtons.Left)
       {
            this.Location = e.Location;
       }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>protected override void OnMouseMove(MouseEventArgs e)
  {
       while (e.Button == System.Windows.Forms.MouseButtons.Left)
       {
            this.Location = e.Location;
        }
  }
  </code></pre>
  
  <p>but neither of these work. Any help is appreciated, and thanks in advance!</p>