将winform放置在屏幕的左下angular

我试图在屏幕的左下angular放置一个表单(在开始button上)我有下面的代码,试图做到这一点,但只考虑到屏幕的工作区域 – 所以窗体位于就在开始button的上方:

int x = Screen.PrimaryScreen.WorkingArea.Left + this.Width; int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height; this.Location = new Point(x, y); 

演示/屏幕如下,以进一步说明我正在尝试做什么:

[Demo Screen](http://i.stack.imgur.com/9mTjj.png)

使用Screen.PrimaryScreen.Bounds属性并设置this.TopMost = true 。 这工作:

 int y = Screen.PrimaryScreen.Bounds.Bottom - this.Height; this.Location = new Point(0, y); this.TopMost = true; 

工作区域通常不包括任何任务栏,停靠窗口和停靠工具栏。 使用Screen.PrimaryScreen.Bounds为您提供完整的屏幕高度和宽度。

示例代码如下所示:

 public Form1() { InitializeComponent(); Rectangle r = Screen.PrimaryScreen.WorkingArea; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - this.Height); this.TopMost = true; } 

这很可能会显示在任务栏下方,因为通常任务栏默认设置为最高。 我记得有一个选项,在Windows XP中关闭该选项,但不知道。

编辑:

在Windows XP中,您可以将任务栏放在窗口后面。 按照链接: 始终在顶部的任务栏上

正如Ria所指出的那样,将这个this.TopMost设置为true,这是一个更好的选择。

你可以试试这个代码

 Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(0, workingArea.Bottom - Size.Height); 

Ria的答案是正确的,但没有添加任务栏高度。
如果您想要显示的图片中的内容,则应使用以下代码:

 int nTaskBarHeight = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom; Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(0, workingArea.Bottom - Size.Height + nTaskBarHeight); this.TopMost = true;