Created
December 10, 2018 18:28
-
-
Save AnshulKuthiala/95cc8b3268bda569fffb76e1a490ffa5 to your computer and use it in GitHub Desktop.
[Move Form] Ability to move form using any component. Useful when form does not have a border.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool MouseDown { get; set; } | |
private System.Drawing.Point LastLocation { get; set; } | |
private void labelGetId_MouseDown(object sender, MouseEventArgs e) | |
{ | |
MouseDown = true; | |
LastLocation = e.Location; | |
} | |
private void labelGetId_MouseMove(object sender, MouseEventArgs e) | |
{ | |
if (MouseDown) | |
{ | |
this.Location = new System.Drawing.Point( | |
(this.Location.X - LastLocation.X) + e.X, (this.Location.Y - LastLocation.Y) + e.Y); | |
this.Update(); | |
} | |
} | |
private void labelGetId_MouseUp(object sender, MouseEventArgs e) | |
{ | |
MouseDown = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment