标签:
不让Form移动到屏幕外,先给窗体添加Move事件,然后判断并重新设置位置。
代码:
private void FormMain_Move(object sender, EventArgs e) { Rectangle r = Screen.GetWorkingArea(this); if(this.Top <=0) { this.Top = r.Top; } if (this.Left <=0) { this.Left = 0; } if (this.Right > r.Right) { this.Left = r.Right - this.Width; } if (this.Bottom > r.Bottom) { this.Top = r.Bottom - this.Height; } }
标签:
原文地址:http://www.cnblogs.com/lantianyuyang/p/5108690.html