private bool mouseDown; private Point lastLocation; private void Form1_MouseDown(object sender, MouseEventArgs e) { mouseDown = true; lastLocation = e.Location; } private void Form1_MouseMove(object sender, MouseEventArgs e) { if(mouseDown) { this.Location = new Point( (this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y); this.Update(); } } private void Form1_MouseUp(object sender, MouseEventArgs e) { mouseDown = false; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter