Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Programmatically Placing a From

Posted on 2006-11-07
4
Medium Priority
?
225 Views
Last Modified: 2010-04-16
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
Comment
Question by:schenkp
  • 3
4 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17894692
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
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 2000 total points
ID: 17894710
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
 

Author Comment

by:schenkp
ID: 17894712
Can you show me one with values please....
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17894750
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question