Try Follow:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool mousedown;
int x, y;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
x = MousePosition.X - DesktopLocation.X;
y = MousePosition.Y - DesktopLocation.Y;
mousedown = true;
}
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if(mousedown)
{
SetBounds(MousePosition.X - y, MousePosition.Y - y, Width, Height);
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
mousedown = false;
}
}
}