vb.net 子窗体的最大化状态在 MDI 容器中使用时无法正常工作 (Visual Basic 2013)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24741914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:51:14  来源:igfitidea点击:

Maximized state of child form Not working correctly when used in MDI container (Visual Basic 2013)

vb.netwinformsvisual-studio-2010visual-studio-2013

提问by Dr. Atul Tiwari

I am having this weird problem in Visual Basic (2013). I have a form in MDI container. Both of them, have property WindowStateto Maximized. While executing, MDI container loads in maximized state (So far Ok!). But, when I open the child form, it Does NOT give the Actual Maximized state appearance(although Restore button on top right shows that it has loaded in maximized state, but it did not maximized).

我在 Visual Basic (2013) 中遇到了这个奇怪的问题。我在 MDI 容器中有一个表单。他们两人,有属性WindowStateMaximized。在执行时,MDI 容器以最大化状态加载(到目前为止还好!)。但是,当我打开子窗体时,它不会给出实际最大化状态的外观(尽管右上角的“还原”按钮显示它已加载到最大化状态,但并未最大化)。

I even tried with form1.WindowState = FormWindowState.Maximizedboth before and after form1.Show(), but no luck.

我什至尝试form1.WindowState = FormWindowState.Maximized了 before 和 after form1.Show(),但没有运气。

I have attached a screenshot too. Note the dead space of MDI container and Restore icon of child form (which means child form is in maximized state).

我也附上了截图。注意MDI容器的死区和子窗体的还原图标(表示子窗体处于最大化状态)。

screenshot of VB problem

VB问题截图

Few observations -

很少观察 -

  1. When I restore and then again maximize it, it DOES maximize correctly.

  2. I also observed that this problem is occurs only for one time. I mean, if I have 2 forms both set to load in Maximized state. When I open the first form (no matter which), it loads like i showed in the screenshot, and after that when I open 2nd form, it loads in maximized state.

  1. 当我恢复然后再次最大化它时,它确实正确最大化。

  2. 我还观察到此问题仅发生一次。我的意思是,如果我有 2 个表单都设置为在最大化状态下加载。当我打开第一个表单(无论哪个)时,它会像我在屏幕截图中显示的那样加载,然后当我打开第二个表单时,它会以最大化状态加载。

I could not figure out, what went wrong? How to correct this?

我想不通,出了什么问题?如何纠正?

回答by yul

go to your form properties. Set windowsState = normal. then put this to code

转到您的表单属性。设置 windowsState = 正常。然后把它写成代码

    Dim frmC As New frmChild
    frmC.MdiParent = Me
    frmC.WindowState = FormWindowState.Maximized
    frmC.Show()

回答by MBAH

I found that setting the MDI child form to maximized within the New routine of the class works always OK.

我发现在类的新例程中将 MDI 子窗体设置为最大化总是可以的。

Public Sub New()
    ' This call is required by the designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    Me.WindowState = FormWindowState.Minimized
End Sub

OK, the last line may be one you may code under a condition...

好的,最后一行可能是您可以在某个条件下编码的行...

回答by Ludwig vonMises

Check your icon. It must contain a 16x16 page. If the smallest is 32x32, the problem you illustrate will arise.

检查您的图标。它必须包含一个 16x16 的页面。如果最小的是32x32,就会出现你说明的问题。