private void Window_LocationChanged(object sender, EventArgs e)
if (this.Left < this.Owner.Left)
this.Left = this.Owner.Left;
if (this.Top < this.Owner.Top)
this.Top = this.Owner.Top;
As you can see the code above written, but I am not able to restrict the window while moving
at the bottom and right of Desktop. Because I am not finding any attribute for that.
Please suggest if Any one has implemented the same.
this.Right would be:
this.Left + this.Width
this.Top + this.Height
So the lines of code that are equivalent to what you have written above, but for right and bottom would be:
if (this.Left + this.Width > this.Owner.Left + this.Owner.Width) this.Left = this.Owner.Left + this.Owner.Width - this.Width; if (this.Top + this.Height > this.Owner.Top + this.Owner.Height) this.Top = this.Owner.Top + this.Owner.Height - this.Height;