本文介绍了通过Windows c中的MDI父窗体在同一位置打开所有子窗体#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我通过MDI父级打开新表单时,无论它是相同还是不同的形式,它都会更改其位置。我认为它必须是默认行为,但我想在同一位置打开所有表单,



如果用户通过MDI父级打开多个表单,最近打开的表单将离开屏幕,用户必须在中心手动拖动它们(这对他们来说很烦人。)



下面是打开孩子的代码通过MDI父母形成



Every time I open a new form through a MDI parent regardless it is same or different form, it changes its location. I assume that it must be a default behavior, But I would like to open all the form at SAME LOCATION,

If user opens multiple forms through a MDI parent, recently opened forms will go out of the screen and user have to drag them manually at the center(this would be annoying for them.)

Below is the code for opening child form through MDI parent

frmCreateClient childForm = new frmCreateClient();
            childForm.MdiParent = this;
            childForm.Text = "New Client";
            childForm.Show();





我试图在上面的代码中添加位置如下,但它没有工作





I tried to add location in the above code as below, but it didn't work

childForm.Location = new Point(15, 15);

推荐答案


frmCreateClient childForm = new frmCreateClient();
childForm.MdiParent = this;
childForm.Text = "New Client";
childForm.StartPosition = FormStartPosition.Manual;
childForm.Location = new Point(15,15); // Always opens the forms at 15,15
childForm.Show();


frmCreateClient childForm = new frmCreateClient();
          childForm.MdiParent = this;
          childForm.Text = "New Client";
          childForm.StartPosition = FormStartPosition.CenterParent;
          childForm.Show();





希望它对你有帮助.....



Hope it helps you.....


这篇关于通过Windows c中的MDI父窗体在同一位置打开所有子窗体#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 13:59