Solved

Positioning form

Posted on 2002-07-06
4
261 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 50 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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