我创建一个新表单并从父表单调用如下:
loginForm = new SubLogin();
loginForm.Show();
Run Code Online (Sandbox Code Playgroud)
我需要在父级的中心显示子表单.所以,在子表单加载中我做了foll:`
Point p = new Point(this.ParentForm.Width / 2 - this.Width / 2, this.ParentForm.Height / 2 - this.Height / 2);
this.Location = p;
Run Code Online (Sandbox Code Playgroud)
但是这会抛出错误,因为父表单为空.我也尝试设置Parent属性,但没有帮助.有什么输入吗?