C# 似乎无法在父窗体中居中mdichild

C# 似乎无法在父窗体中居中mdichild,c#,winforms,C#,Winforms,我在单击菜单时尝试了以下操作,但表单仍然显示在mdichild的左上角。我也尝试了手动定位,但不起作用 有什么建议吗 Form1 form= new Form1{MdiParent = this}; form.StartPosition = FormStartPosition.CenterParent; form.Show(); 试一试 @用户231465,这对我有用(使用了3行代码并使用了CenterScreen)CenterParent在调用ShowDialo

我在单击菜单时尝试了以下操作,但表单仍然显示在mdichild的左上角。我也尝试了手动定位,但不起作用

有什么建议吗

     Form1 form= new Form1{MdiParent = this};
     form.StartPosition = FormStartPosition.CenterParent;
     form.Show();
试一试


@用户231465,这对我有用(使用了3行代码并使用了
CenterScreen
CenterParent
在调用
ShowDialog
时起作用,但是
form
不能是mdi子级。刚刚了解了为什么不起作用。基本上1)启动应用程序2)mdiParent没有最大化3)最大化表单不会使mdichild居中。如果在启动子级之前最大化mdiParent,则可以工作。我在mdiparent设置的resize事件中添加了代码,将activechild的startposition设置为CenterScreen,但没有work@user231456为此,必须设置form.Left和form.Top属性。
form.StartPosition = FormStartPosition.CenterScreen ;