我尝试每次都在相同位置用 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
}
窗口属性 StartPosition =Manual
但结果 - 让我的窗口始终在左上角打开。
尝试为 x 和 y 设置不同的值 - 结果相同。
我做错了什么?
最佳答案
希望对你有帮助
int x = Screen.PrimaryScreen.WorkingArea.Top;
int y = Screen.PrimaryScreen.WorkingArea.Left;
this.Location = new Point(x, y);
关于c# - 新窗口打开后的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18556538/