【发布时间】:2013-09-04 13:52:32
【问题描述】:
我每次都尝试在 C# (WinForms) 中打开新窗口的相同位置。 尝试使用此代码:
private void Notification_Load(object sender, EventArgs e)
{
Rectangle screenSize = Screen.PrimaryScreen.Bounds; //get resolution of screen
int x = screenSize.Height -115-30; //x coordinate = resolution of screen - window Height - 30 (for taskbar)
int y = screenSize.Width - 345; //y coordinate = resolution of screen - window Weight
this.SetDisplayRectLocation(x, y); //new coordinates for form
}
windows 的属性 StartPosition =Manual
但结果 - 总是让我的窗口在左上角打开。
尝试为 x 和 y 设置不同的值 - 结果相同。
我做错了什么?
【问题讨论】:
-
为什么不直接设置
this.Left和this.Top值? -
为什么你的
x = Height和y = Width?