Tag: 父子对中

FormStartPosition.CenterParent不起作用

在下面的代码中,只有第二种方法适用于我(.NET 4.0)。 FormStartPosition.CenterParent不会将子表单置于其父表单的中心。 为什么? 资料来源: 这个问题 using System; using System.Drawing; using System.Windows.Forms; class Program { private static Form f1; public static void Main() { f1 = new Form() { Width = 640, Height = 480 }; f1.MouseClick += f1_MouseClick; Application.Run(f1); } static void f1_MouseClick(object sender, MouseEventArgs e) { Form f2 = new Form() { Width […]

如何将CenterParent转换为非模态forms

我有一个非模态子表单,从父表单打开。 我需要将子表单居中到其父表单。 我已将子表单的属性设置为CenterParent并尝试了此操作: Form2 f = new Form2(); f.Show(this); 但无济于事。 这适用于模态forms,但非模态forms则不然。 任何简单的解决方案,还是需要我通过所有数学计算来确定其位置为中心?