在VB.NET中是否有“Restore Down”事件

时间:2013-12-17 08:11:53

标签: winforms vb.net-2010

当我点击标题栏中的“恢复向下”按钮然后它会恢复主窗体以及我声明的特定尺寸的其他窗体时,会适​​合什么事件。 我是vb.net的新手,仍在探索新功能。请帮忙!

3 个答案:

答案 0 :(得分:1)

为c#解决方案道歉,也许这会帮助您将其转换为VB.Net。我不知道有任何更好的解决方案,但这应该有效。

private FormWindowState? previousWindowState;
protected override void OnSizeChanged(EventArgs e)
{
    if (this.Bounds == this.RestoreBounds && previousWindowState.HasValue && previousWindowState.Value == FormWindowState.Maximized)
    {
        Console.WriteLine("Restored down");
    }
    previousWindowState = this.WindowState;
    base.OnSizeChanged(e);
}

答案 1 :(得分:1)

改编了斯里兰卡对vb.net的回答

Private Sub MotionManagerDialog_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
    If Me.Bounds.Equals(Me.RestoreBounds) And Not PreviousWindowState.Equals(Nothing) And
                        PreviousWindowState.Equals(System.Windows.Forms.FormWindowState.Maximized) Then
        ' Captures restore down action
    End If
    PreviousWindowState = Me.WindowState
End Sub

答案 2 :(得分:0)

要阐明Wylie的答案:您还需要在某处声明PreviousWindowState:

Dim PreviousWindowState As FormWindowState