Surya sasidhar
Surya sasidhar

Reputation: 30343

Window positioning in C#?

When I run my application I want to display my window at right side bottom above the task bar. How do I do that?

Upvotes: 0

Views: 298

Answers (4)

anon
anon

Reputation:

You can obtain the size of the screen as a Rectangle object from the Screen.PrimaryScreen.WorkingArea property.

You can use this information to set the Left and Top properties of your form to the difference between the widths and heights of the Screen rectangle and your form, as such:

private void Form1_Load(object sender, EventArgs e)
{
   Rectangle screen = Screen.PrimaryScreen.WorkingArea;
   this.Left = screen.Width - this.Width;
   this.Top = screen.Height - this.Height;
}

Upvotes: 2

Nick Bedford
Nick Bedford

Reputation: 4445

Screen.PrimaryScreen.WorkingArea

Upvotes: 0

rahul
rahul

Reputation: 187110

You can use the

Form.DesktopLocation Property

Desktop coordinates are based on the working area of the screen, which excludes the taskbar. The coordinate system of the desktop is pixel based. If your application is running on a multimonitor system, the coordinates of the form are the coordinates for the combined desktop.

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180948

Here's an article that describes how to do it.

http://dotnetperls.com/position-windows

Upvotes: 2

Related Questions