我创建了一个新表单,并从父表单中调用,如下所示:
loginForm = new SubLogin();
loginForm.Show();
我需要将子窗体显示在父窗体的中心。所以,在子窗体加载时,我执行以下操作:
Point p = new Point(this.ParentForm.Width / 2 - this.Width / 2, this.ParentForm.Height / 2 - this.Height / 2);
this.Location = p;
但是这会抛出错误,因为父表单为null。我尝试设置Parent属性,但没有帮助。对此有任何建议吗?