Windows应用程序父子关系 [英] windows application parent child relation

查看:147
本文介绍了Windows应用程序父子关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个孩子,该孩子应该在父页面的中心.

当我最小化父窗体时,它应该居中,而当我最大化父窗体时,它应该居中.

怎么样?

希望您回复我.

Hi,

I have a child which should be in the centre of parent page.

When I minimize the parent it should be in centre, same when I maximize parent form.

How?

I hope you reply to me.

推荐答案

如果您将子窗体显示为模态对话框(使用ShowDialog),则可以将StartPosition属性设置为CenterParent并将其设置为CenterParent (最初)正确.
如果没有,那么您将必须手动进行操作:
将StartPosition设置为Manual
首次显示时,请相对于当前表单设置其位置
If you are showing your child form as a Modal dialog (using ShowDialog) then you can set the StartPosition property to CenterParent and it will (initially) be correct.
If not, then you will have to do it manually:
Set the StartPosition to Manual
When you first show it, set it''s Location relative to the current form
frmChild f = new frmChild();
f.Top = ((Height - f.Height) / 2) + Top;
f.Left = ((Width - f.Width) / 2) + Left;
f.Show();

您还必须处理父表单的Resize事件,并在那里进行相同的操作.

[edit]为什么我说进度栏"而不是子表格"?需要咖啡... [/edit]

You will also have to handle the parent form Resize event and do the same there.

[edit]Why did I say "progress bar" instead of "child form"? Need coffee...[/edit]


如果您正在谈论WinForm应用程序,我建议您使用
固定在其父控件的顶部",左侧",底部",右侧"的TableLayoutpanel.

干杯

曼弗雷德(Manfred)
If you''re talking about a WinForm application I''d suggest you use a
TableLayoutpanel that is anchored to the Top, Left, Bottom, Right of its parent control.

Cheers

Manfred


嗨narendra999

Ther是表单的一个属性,用于显示
的位置 在菜单上单击编写此代码

Hi narendra999

Ther is a property of the form to display position of the
On the menu click write this code

Form form1=new Form();
form1.Show();
form1.MdiParent=this;
form1.StartPosition = FormStartPosition.CenterScreen;


这篇关于Windows应用程序父子关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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