我尝试每次在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设置不同的值 - 结果相同。
我做错了什么?
答案 0 :(得分:3)
我希望这会有所帮助
int x = Screen.PrimaryScreen.WorkingArea.Top;
int y = Screen.PrimaryScreen.WorkingArea.Left;
this.Location = new Point(x, y);
答案 1 :(得分:1)
使用
this.Left
this.Top
表格的属性
this.SetDisplayRectLocation
用于在可滚动的表单中设置视图位置:
http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.setdisplayrectlocation.aspx
答案 2 :(得分:1)
试试这个:
this.Location=new Point(x,y);