Visual Studio C# how to move a button's X position by mouse without flicker
<p>So I'm trying to make a slider. I'm using my cursor to move a button's x position.</p>

<p>I have 3 functions, the mouseDown, mouseUp and the mouseMove function. In the mouseUp and mouseDown functions I set a variable to true and false to tell the program that the mouse is clicked or not. In the mouseMove function I tell the program to set the button's x position to the x position of the mouse when the mouse is clicked. This works but has 2 problems.</p>

<p>The first problem is that when I press the button and move it, the button moves along with the mouse's x but it has a space between the mouse and the button. It looks a bit like this:
CURSOR.......BUTTON
The space between the cursor and button change when I change the resolution of the form.</p>

<p>The second problem is that when I move the button it flickers a bit. It only does this at higher speeds but it is a problem in my case.</p>

<p>My code looks like this:</p>

<pre><code>bool mouseDown = false;

private void volumeGrabBT_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        mouseDown = true;
    }
}

private void volumeGrabBT_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        mouseDown = false;
    }
}

private void volumeGrabBT_MouseMove(object sender, MouseEventArgs e)
{
    if (mouseDown == true)
    {
        Point volumeBTPoint = new Point();
        volumeBTPoint.X = Cursor.Position.X;
        volumeBTPoint.Y = volumeGrabBT.Location.Y;
        volumeGrabBT.Location = volumeBTPoint;
    }
}
</code></pre>

<p>The volumeGrabBT is the button I'm trying to move along with the mouse.
The volumeBTPoint is the point of the button I'm trying to set the button's position to.</p>

<p>I hope someone can help me fix these problems. Thanks in advance!</p>