C# 将 WinForm 放在右下角
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1385674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Place WinForm On Bottom-Right
提问by
How can I place a form at the bottom-right of the screen when it loads using C#?
使用 C# 加载表单时,如何将其放置在屏幕的右下角?
采纳答案by Noam Gal
try something on the lines of
尝试一些东西
Rectangle workingArea = Screen.GetWorkingArea(this);
this.Location = new Point(workingArea.Right - Size.Width,
workingArea.Bottom - Size.Height);
Hope it works well for you.
希望它对你有用。
回答by flayto
In you form constructor put the following code:
在您的表单构造函数中放置以下代码:
StartPosition = FormStartPosition.Manual;
This will set the start position of the form to whatever you set as the value for the form's location (you can set this in the form designer).
这会将表单的开始位置设置为您设置为表单位置值的任何值(您可以在表单设计器中进行设置)。
回答by adatapost
Form2 a = new Form2();
a.StartPosition = FormStartPosition.Manual;
a.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - a.Width,
Screen.PrimaryScreen.WorkingArea.Height - a.Height);
回答by Andrew Bucklin
This worked for me; i just put this code listed below after my InitializeComponent();
这对我有用;我只是把下面列出的代码放在我的后面InitializeComponent();
public FormProgress()
{
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
}
回答by Umut D.
It's easy to try;
很容易尝试;
//Get screen resolution
Rectangle res = Screen.PrimaryScreen.Bounds;
// Calculate location (etc. 1366 Width - form size...)
this.Location = new Point(res.Width - Size.Width, res.Height - Size.Height);