Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;namespace Mouse Drag move coordinates {public ' partial class Form1:form {public F Orm1 () {InitializeComponent (); } private bool isOK; private int x; Mouse point down the horizontal axis private int y;//Mouse point down the ordinate private int cx; private int cy; private void Form1_mousedown (object sender, MouseEventArgs e)//point down {isOK = true; x = cursor.position.x; Mouse point down when the form of the horizontal axis y = cursor.position.y;//Mouse point down when the form of the ordinate CX = this. location.x;//form Initial horizontal axis cy = this. location.y;//form initial ordinate} private void Form1_mouseup (object sender, MouseEventArgs e)//release { isOK = false; } private void Form1_mousemove (object sender, MouseEventArgs e)//move {if (isOK) { int Movex= cursor.position.x; The horizontal axis of the move process int Movey = cursor.position.y;//The ordinate this of the move process. Location = new Point (CX+MOVEX-X,CY+MOVEY-Y); Initial coordinates + moving coordinates-the mouse at the beginning of the point down the coordinates}}}}
Drag the mouse to move coordinates