The code is relatively simple, not much to parse.
#regionMove a form to save dataPoint Mouseoff;//mouse Move position variable BOOLLeftflag;//whether the flag is left button BOOLLargeflag;//whether the flag changes width and height at the same time BOOLWidthflag;//whether the flag changes width BOOLHeightflag;//whether the flag changes height /// <summary> ///Mouse Movement/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidForm1_mousemove (Objectsender, MouseEventArgs e) {Point Mouseset=control.mouseposition; if(leftflag) {//Change the width and height if(largeflag) {intDW = Mouseset.x- This. location.x; intDH = mouseset.y- This. LOCATION.Y; This. Width =DW; This. Height =DH; } //Change Width Else if(widthflag) {intDW = Mouseset.x- This. location.x; This. Width =DW; } //Change Height Else if(heightflag) {intDH = mouseset.y- This. LOCATION.Y; This. Height =DH; } //Move Position Else{mouseset.offset (mouseoff.x, mouseoff.y);//set the position after the move This. Location =Mouseset; } } Else { //set the flag to change the width of the form if(( This. Location.x + This. Width-mouseset.x) <Ten&& ( This. LOCATION.Y + This. HEIGHT-MOUSESET.Y) <Ten) { This. Cursor =Cursors.sizenwse; Largeflag=true; } //set a flag that changes the width of the form Else if(( This. Location.x + This. Width-mouseset.x) <Ten) { This. Cursor =Cursors.sizewe; Widthflag=true; } //set the flag to change the height of the form Else if(( This. LOCATION.Y + This. HEIGHT-MOUSESET.Y) <Ten) { This. Cursor =Cursors.sizens; Heightflag=true; } //set the flag for the move position Else { This. Cursor =Cursors.Default; Largeflag=false; Widthflag=false; Heightflag=false; } } } /// <summary> ///mouse button down/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidForm1_mousedown (Objectsender, MouseEventArgs e) { if(E.button = =mousebuttons.left) {Mouseoff=NewPoint (-e.x,-e.y);//get the value of a variableLeftflag =true;//Click on the left button when the label is true; } } /// <summary> ///Mouse pop up/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidForm1_mouseup (Objectsender, MouseEventArgs e) { if(leftflag) {Leftflag=false;//label false after releasing the mouse; } } #endregion
C # Move and change control size