Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Programmatically Placing a From

Hi,
How do i Programmatically place a form on the screen?  I have a need to place it off center when the program starts?
0
schenkp
Asked:
schenkp
  • 3
1 Solution
 
Jase-CoderCommented:
Hi

You can use the following method:

public static void SetWindowPosition (
      int left,
      int top
)


this method can only be used in .NET 2 and above
0
 
Jase-CoderCommented:
sorry that was a mistake. That method is for setting ths position of a console window. To set the position of Window you can do:

this.Top = whatever;
this.Left = whatever;
0
 
schenkpAuthor Commented:
Can you show me one with values please....
0
 
Jase-CoderCommented:
yeh no problem

button a button on a form and do

        private void button1_Click(object sender, EventArgs e)
        {
            this.Top = 20;
            this.Left = 40;
        }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now