如何让mdi child固定在mdi parent中 [英] how to make mdi child fixed in mdi parent

查看:139
本文介绍了如何让mdi child固定在mdi parent中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我即将成为程序员并且正在使用c#。我的项目有几种形式,表格是用mdi工作的。我有一个表格是mdi父母,其余的作为mdi孩子,但任何时候我在mdi父母中运行我的mdi子表格,表格的大小增加,表格中的工具也增加。但我希望mdi孩子的大小固定,工具太固定,因此不可更改

hello am upcoming programmer and am working in c#. i have several forms in my project and the forms are to work in mdi. i have one form to be mdi parent and the rest as mdi child but anytime i run my mdi child form in the mdi parent the size of the form increases and the tools in the form also increases. but i want the mdi child to fixed in size with the tools too fixed thus unchangeable

推荐答案

你观察到的重新调整大小很可能是由你的孩子造成的字体大小的设置:当它们在父窗体中创建和激活时,它们会重新调整大小,因为它们继承父窗体的字体设置,这会导致控件重新调整大小,从而导致子窗体重新调整大小。



我认为它是WinForm MDI实现的一般缺陷(即过时的多窗口控制策略中的许多缺陷之一),即使是Child Form的自动大小property设置为'false(默认值),Form将根据Parent Form的font属性设置重新调整大小。更糟糕的是,在我看来,如果你设置一个Form的MinimumSize和MaximumSize属性:当Form作为MDI Child实例化/激活时,这些属性会被忽略。



但是,请注意,即使您创建了一个独立的(不是MDI子窗体)窗体,并设置了特定的MinimumSize和MaximumSize,并且将AutoSize设置为为false,如果该窗体上的控件具有默认的字体设置...继承自Form的设置......并且您更改了Form的Font设置:不仅这些控件会重新调整大小,而且Form也会重新调整大小。



我很遗憾地告诉你,在Visual Studio 2015和FrameWork 4.6的WinForms中,这种行为仍在继续。



请记住,当你有Font时参数在独立Windows窗体中设置为默认值,表单可以继承某些属性,这些属性在Windows中由用户设置在系统范围内定义:即Windows使用的主题。



这是怎么回事为了防止这种情况:



1.对MDI父表和子表使用一致的字体设置



2.和/或确保明确将父或子表单中使用的字体设置为非系统默认值。



3.和/或如果父表单使用默认字体设置,请确保子表单没有。



如果您在实例化/激活子表单时观察到任何控件重新调整大小在父窗体中:在设计时模式下返回并检查控件的Font属性。
Most likely the re-sizing you observe is caused by your child Forms using default settings for Font size: when they are created and activated inside the parent Form, they re-size because they "inherit" the parent Form's font setting, which causes the Controls to re-size, which causes the child Form to re-size.

I regard it as a general flaw of WinForm MDI implementation (one of many flaws in that outmoded multi-window control strategy) that even if the Child Form's Auto-Size property is set to 'false (the default), the Form will re-size based on the Parent Form's font property setting. Even worse, in my opinion, is that if you set the MinimumSize and MaximumSize properties of a Form: those are ignored when the Form is instanced/activated as an MDI Child.

But, note that even if you create a stand-alone (not an MDI Child Form) Form, and have set specific MinimumSize and MaximumSize, and have 'AutoSize set to 'false, if the Controls on that Form have default Font settings ... inherited from the settings of the Form ... and you change the Form's Font setting: not only will those Controls re-size, but the Form will re-size, also.

I regret to tell you this behavior is still going on in WinForms in Visual Studio 2015, and FrameWork 4.6.

Remember that when you have Font parameters set to default in a "stand-alone" Windows Form that the Form may inherit certain attributes that are defined system-wide in Windows by the user settings: i.e., the theme that Windows uses.

Here's how to prevent this:

1. Use a consistent font-setting for both MDI Parent and Child Forms

2. and/or Make sure you explicitly set the Font used in your Parent or Child Forms to one that is not a system default.

3. and/or if the Parent Form is using default Font settings, make sure the Child Forms do not.

If you observe any Controls re-sizing when the Child Form is instanced/activated in the Parent Form: in design-time mode go back and examine the Font property of the Controls.


这篇关于如何让mdi child固定在mdi parent中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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