Form position on lower right corner of the screen(屏幕右下角的窗体位置)
问题描述
我正在使用c#WinForm开发一个sman通知应用程序。我想把主窗体放在屏幕工作区的右下角。 如果有多个屏幕,是否有办法找到放置应用程序的最右侧屏幕,或者至少记住上次使用的屏幕并将窗体放在其右下角?
推荐答案
我当前没有多个要检查的显示器,但应该类似于
public partial class LowerRightForm : Form
{
public LowerRightForm()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
PlaceLowerRight();
base.OnLoad(e);
}
private void PlaceLowerRight()
{
//Determine "rightmost" screen
Screen rightmost = Screen.AllScreens[0];
foreach (Screen screen in Screen.AllScreens)
{
if (screen.WorkingArea.Right > rightmost.WorkingArea.Right)
rightmost = screen;
}
this.Left = rightmost.WorkingArea.Right - this.Width;
this.Top = rightmost.WorkingArea.Bottom - this.Height;
}
}
这篇关于屏幕右下角的窗体位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!