Display Windows Form in Position(L, R, T, B) Anywhere

Hi All,
I have a situation to bring my form in right bottom of a screen in c#. After i get my answer i make my form to go anywhere in screen. i have given that code to move form in 9 position in screen

if you feel this is useful drop comments.

private void button1_Click(object sender, EventArgs e)
{
//Top Left
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(0, 0);
}

private void button2_Click(object sender, EventArgs e)
{
//Top Right
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x, 0);
}

private void button3_Click(object sender, EventArgs e)
{
//Center
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x / 2, y / 2);
}

private void button4_Click(object sender, EventArgs e)
{
//Bottom Left
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(0, y);
}

private void button5_Click(object sender, EventArgs e)
{
//Bottom Right
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x, y);
}

private void button6_Click(object sender, EventArgs e)
{
//Top Center
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x / 2, 0);
}

private void button7_Click(object sender, EventArgs e)
{
//Left Center
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(0, y / 2);
}

private void button8_Click(object sender, EventArgs e)
{
//Bottom Center
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x / 2, y);
}

private void button9_Click(object sender, EventArgs e)
{
//Right Center
int x = Screen.PrimaryScreen.WorkingArea.Width – this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Height – this.Height;
this.Location = new Point(x, y / 2);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s