![](/img/trans.png)
[英]When we have multiple windows forms in our C# application, how to make one form as opening form
[英]How to position the opening form at specific location in C# Windows Forms?
表单中的Location
属性设置为0,0(“属性窗口”)。 但是,该窗体不会在指定的位置打开。 我想念什么吗?
您需要将StartPosition
设置为manual,以使表单将开始位置设置为Location
Property中的值。
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(0, 0);
}
智能感知摘要FormStartPosition.Manual
FormStartPosition FormStartPosition.Manual
窗体的位置由System.Windows.Forms.Control.Location属性确定 。
默认情况下,起始位置设置为WindowsDefaultLocation,这将导致表单忽略您正在设置的位置。 要轻松执行设置的位置,请将StartPosition更改为Manual。
尝试:
this.Location = new Point(Screen.PrimaryScreen.Bounds.X, //should be (0,0)
Screen.PrimaryScreen.Bounds.Y);
this.TopMost = true;
this.StartPosition = FormStartPosition.Manual;
如果忘记将StartPosition设置为FormStartPosition,则将Location设置为0,0无效。
使用此属性,可以设置在运行时显示窗体的开始位置。 可以通过设置Location属性来手动指定表单的位置,也可以使用Windows指定的默认位置。 对于诸如多文档界面(MDI)子窗体之类的窗体,您还可以将窗体放置在屏幕的中心或其父窗体的中心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.