private void Form1_LocationChanged(object sender, EventArgs e) { Rectangle rect = new Rectangle(); rect = Screen.GetWorkingArea(this); if (this.Location.Y< 0) this.Location = new Point(this.Location.X,0); if (this.Location.X < 0) this.Location = new Point(0, this.Location.Y); if (this.Bottom >= rect.Height) this.Location = new Point(this.Location.X, rect.Height - this.Height); if (this.Right >= rect.Width) this.Location = new Point(rect.Width - this.Width, this.Location.Y); }