Position a form in the screen’s lower right corner in C#

[position a form]

The Screen.PrimaryScreen.WorkingArea property gives the size of the primary screen’s working area. (For more information, see Get the screen’s working area in C#).

The following code subtracts the form’s width and height plus a margin from the working area’s Right and Bottom values> It then uses the results to position a form in the lower right corner.

// Position the form in the lower right corner of the working area.
private void Form1_Load(object sender, EventArgs e)
    const int margin = 10;
    int x = Screen.PrimaryScreen.WorkingArea.Right -
        this.Width - margin;
    int y = Screen.PrimaryScreen.WorkingArea.Bottom -
        this.Height - margin;
    this.Location = new Point(x, y);

Download Example   Follow me on Twitter   RSS feed   Donate

This entry was posted in system and tagged , , , , , , , , . Bookmark the permalink.

2 Responses to Position a form in the screen’s lower right corner in C#

  1. Anonymous says:

    It looks like the download link for this one has a rogue ‘a’ in the filename causing the download link to break.

  2. Rod Stephens says:

    Oops! Thanks for pointing this out. I’ve fixed it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.