【问题标题】:Preventing a window from leaving MDI without twitching?防止窗口在不抽动的情况下离开 MDI?
【发布时间】:2012-03-18 15:53:48
【问题描述】:

在我的 Form1 的 Move 事件中,我检查它的位置,如果它超出了用户的视野,我将它移回。当他完成移动它时是否会触发一个事件?因为移动事件在移动时会触发,所以我需要它在移动之后。到目前为止,这是我的代码:

    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; }
    }

【问题讨论】:

标签: c# winforms events window mdi


【解决方案1】:

尝试在 ResizeEnd 事件中执行移动校正例程。令人惊讶的是,它不仅会在调整表单大小时触发,而且还会在用户移动表单时触发。

阅读更多Form.ResizeEnd Event

【讨论】:

    猜你喜欢
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-04
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    相关资源
    最近更新 更多