You will need to record when the mouse is up and down using the MouseDown and MouseUp :
private bool mouseIsDown = false; private Point firstPoint; private void Form1_MouseDown(object sender, MouseEventArgs e) { firstPoint = e.Location; mouseIsDown = true; } private void Form1_MouseUp(object sender, MouseEventArgs e) { mouseIsDown = false; }
As you can see, the first point is recorded, so you can use the MouseMove as follows:
private void Form1_MouseMove(object sender, MouseEventArgs e) { if (mouseIsDown) {
source share