当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - position of new windows after opening

问题描述:

I try to open new window in C# (WinForms) in same position each time.

Try to use this code:

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

}

properties of windows StartPosition =Manual

but as result - have that always my window open in the upper left corner.

try to put different value for x and y - result the same.

what i'm doing wrong?

网友答案:

I hope this helps

 int x = Screen.PrimaryScreen.WorkingArea.Top;
 int y = Screen.PrimaryScreen.WorkingArea.Left;
 this.Location = new Point(x, y);
网友答案:

Use the

this.Left
this.Top

properties of the form

this.SetDisplayRectLocation is for setting the view location within a scrollable form: http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.setdisplayrectlocation.aspx

网友答案:

try this:

this.Location=new Point(x,y);
分享给朋友:
您可能感兴趣的文章:
随机阅读: