0
在我的Form1的移動事件,我檢查它的位置,如果它出了用戶的觀點我將其移回。當他完成移動時會發生什麼事件?因爲移動事件在被移動時觸發,我需要在它移動之後。這是我到目前爲止的代碼:防止不抽搐的窗口離開MDI?
private void PublicTicker_Move(object sender, EventArgs e)
{
if (this.Left < 0)
{ this.Left = 0; }
else if (this.Left > this.MdiParent.ClientRectangle.Width - this.Width)
{ this.Left = this.MdiParent.ClientRectangle.Width - this.Width; }
if (this.Top < 3)
{ this.Top = 3; }
else if (this.Top > this.MdiParent.ClientRectangle.Height - this.Height)
{ this.Top = this.MdiParent.ClientRectangle.Height - this.Height; }
}
[移動形式只會垂直]的可能重複(http://stackoverflow.com/questions/4302440/move-form-only-vertically) – 2012-03-18 16:51:02