Inhibiting form movement

  • Thread starter Thread starter > Adrian
  • Start date Start date
A

> Adrian

Is there a way to inhibit moving the form on screen?
Thank you,
Adrian.
 
Hi Adrian,

Presumably, something like this should work:

public class Form1 : Form {
Point location;

protected override void OnShown(EventArgs e) {
base.OnShown(e);
location = this.Location;
}

protected override void OnMove(EventArgs e) {
base.OnMove(e);
if(!this.Location.Equals(location)) {
this.Location = location;
}
}
}
 
Thank you very much.
Adrian.

Bram said:
Hi Adrian,

Presumably, something like this should work:

public class Form1 : Form {
Point location;

protected override void OnShown(EventArgs e) {
base.OnShown(e);
location = this.Location;
}

protected override void OnMove(EventArgs e) {
base.OnMove(e);
if(!this.Location.Equals(location)) {
this.Location = location;
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top