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

x
?
Solved

Positioning form

Posted on 2002-07-06
4
Medium Priority
?
295 Views
Last Modified: 2010-04-15
I have a form and from MainMenu show second form. 2 form is created in c-tor of main form.
I try this from c-tor and OnLoad to position second form right to first but doesnt work
second.Left = this.Right;
second.Top = this.Top;
I put the same in OnMove and after move main form all is OK but after first show of 2 form it doesnt work
0
Comment
Question by:plamtod
4 Comments
 
LVL 1

Expert Comment

by:GuryTraub
ID: 7135081
I dont quite follow your description.
But what I can tell you is this :

You should check whether the this.Right is known when you give it the other form.

maybe you are using the wrong Event..

Try just loading the first form with a button, and when clicking the button, on the before load of the new Form, set the new values..

Gury
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7135579
Place in onload of second form:

this.Left = this.Parent.Right
this.Top = this.Parent.Top

0
 

Accepted Solution

by:
tijskex earned 200 total points
ID: 7145740
No time to test in deep, but I guess it has something to do with the StartFormPosition property: When constructor looks like this, then it works:

public Form1(){
  InitializeComponent();
  secondForm=new Form2();
  secondForm.Visible=true;
  this.StartPosition =
       System.Windows.Forms.FormStartPosition.Manual;
  this.Location=new System.Drawing.Point(250,250);
  secondForm.StartPosition =
       System.Windows.Forms.FormStartPosition.Manual;
  secondForm.Location=
          new System.Drawing.Point(this.Right,this.Top);
}

Drawback of this is that you have to set the position of Form1 manually and you cannot use CenterScreen or something like that as FormStartPosition.

Hope this can be of some help.

Bart.

0
 

Author Comment

by:plamtod
ID: 7145810
OK
I too come to this decision
Thanks
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

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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 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