使用C#.net打开子窗体时如何更改其窗口大小 [英] how to change the windowsize of a childform,when it opens using C#.net

查看:855
本文介绍了使用C#.net打开子窗体时如何更改其窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打开子窗体时,它将以最大尺寸打开.我想减小子窗体的大小,并使用c#.net(windows应用程序)将其固定在父窗体的特定位置.

When a child form opens,it opens in maximum size.i want to reduce the size of the childform and fix it in a particular position in a parent form using c#.net(windows application).

推荐答案

对您的代码的一些观察:现在我们知道您有点滥用MDI:

1.您正在将面板插入面板:使用或不使用MDI体系结构都不是一个好主意.

2.由于您正在使用MDI,因此要设置表单的MDIParent属性,而不是Parent属性.

2.您是否尝试过设置您创建的Form的StartPosition属性?尝试将其设置为手动",然后为新窗体的显示"事件定义一个事件处理程序,在该事件中,您需要执行将窗体相对于其容器定位的操作.

而且,请仔细阅读MDI并考虑不使用它:它已被弃用",这意味着在当前时间,它不被认为是对多形式体系结构的一个好的解决方案. />
最好,Bill
Some observations on your code: now that we know you are kind-of mis-using MDI:

1. you are inserting a Form into a Panel: that''s not a good idea either using, or not using, MDI architecture.

2. Since you are using MDI, you want to be setting a Form''s MDIParent property, not Parent property.

2. Have you tried setting the Form you create''s StartPosition property ? Try setting it to ''Manual,'' and then define an Event Handler for the new Form''s ''Shown'' Event in which you do what you need to do position the Form in relation to its container.

And, please read up on MDI, as well as consider not using it: it''s been "deprecated," meaning it''s not thought of as a good solution to multi-form architecture at this point in time.

best, Bill


Load事件处理程序中设置表单的WidthHeightLocation属性.您还应该将Parent属性设置为对父表单的引用,以便获取该表单在屏幕上的位置.
Set the form''s Width, Height, and Location properties in the Load event handler. You should also set the Parent property to a reference to the parent form so you can get that form''s location on the screen.


这篇关于使用C#.net打开子窗体时如何更改其窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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