Heyho, here's an example of what i used in my application to move a borderless form.
Put this pointer and a bool outside any event:
ExampleCode:private Point LastCursorPosition; private bool IsMouseDown;
Code:private Point LastCursorPosition; private bool IsMouseDown; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Do something }
Put this in your Form1_MouseDown event.
Put this in your Form1_MouseUp event.Code:this.IsMouseDown = true; this.LastCursorPosition = new Point(e.X, e.Y);
put this in your Form1_MouseMove eventCode:this.IsMouseDown = false;
That's it! it's simpleCode:if (this.IsMouseDown == true) { //Move the form this.Location = new Point(this.Left - (this.LastCursorPosition.X - e.X), this.Top - (this.LastCursorPosition.Y - e.Y)); //Redraw the form// this.Invalidate(); }![]()