即使WindowState设置为Maximized,窗体也不会显示为最大化 [英] Form won't display as maximized even though WindowState is set to Maximized

查看:380
本文介绍了即使WindowState设置为Maximized,窗体也不会显示为最大化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我刚刚想出了一个解决这个问题的方法,就是在FormLoad事件中简单地将WindowState设置为Maximized,但我会仍然想知道为什么在设计时设置WindowState失败。

这里发生了很奇怪的错误。我有一个MDI项目,当我的项目中的任何子表单初始显示时,它们将不会显示最大化。表单的标题栏已最大化,但表单本身以常规大小状态显示。它很奇怪,因为表单知道它应该最大化,因为标题栏最大化,你不能调整表单大小。

如果我单击还原按钮,然后单击最大化按钮,它将完全显示按预期最大化国家。它只是在表单最初显示时才会显示为最大化。相关的表单属性设置如下:

WindowState = Maximized
StartPosition = CenterScreen
Maximim Size = 0,0
FormBorderStyle = resizable

我已经尝试了所有的各种StartPosition值并没有区别。下面的代码是负责显示表单的MdiParent表单上的代码(顺便说一句,mdi父项也设置为最大化,并且它最大化没有问题)。正如您所看到的,我正在使用默认实例(在实例化新对象时也会出现问题)。我的其他项目都没有显示这个问题,只有这个项目。感谢您的时间!

ServiceMaintenanceForm.MdiParent =我
ServiceMaintenanceForm.BringToFront()
ServiceMaintenanceForm.Show()


解决方案

什么时候发生....

StartPosition = WindowsDefaultStartPosition;

设置如此?搜索结果,搜索Rudedog(未测试的),点击

NOTE: I just figured out a solution to this problem, which was to simply set the WindowState to Maximized in the FormLoad event, but I would still like to know why setting the WindowState at design time is failing.

Very weird error going on here.  I have an MDI project and whenever any of the child forms in my project are initally displayed, they will not display maximized.  The title bar for the form is maximized but the form itself is showing in its regular sized state.  Its weird because the form knows it should be maximized because the title bar is maximized and you can't resize the form.

If I click the restore button and then click the maximize button, it will display in its fully maximized state as expected.  Its just when the form is initially displayed that it won't display as maximized.  Related form properties are set as follows:

WindowState = Maximized
StartPosition = CenterScreen
Maximim Size = 0,0
FormBorderStyle = resizable

I have tried all of the various StartPosition values and that makes no difference.  The code below is the code on the MdiParent form that is responsible for displaying the form (BTW, the mdi parent is set to be maximized also and it maximizes with no problem).  As you can see I'm using the default instance (problem occurs when instantiating a new object also).  None of my other projects are displaying this problem, only this one project.  Thanks for your time!

        ServiceMaintenanceForm.MdiParent = Me
        ServiceMaintenanceForm.BringToFront()
        ServiceMaintenanceForm.Show()


解决方案

What happens when ....

StartPosition = WindowsDefaultStartPosition;

is set like that? 

Rudedog
(untested)


这篇关于即使WindowState设置为Maximized,窗体也不会显示为最大化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆