Positioning form

Posted on 2002-07-06
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
Question by:plamtod
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

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..

LVL 22

Expert Comment

ID: 7135579
Place in onload of second form:

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


Accepted Solution

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(){
  secondForm=new Form2();
  this.StartPosition =
  this.Location=new System.Drawing.Point(250,250);
  secondForm.StartPosition =
          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.



Author Comment

ID: 7145810
I too come to this decision

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Set custom font WPF 2 26
array not updating 8 42
Build a string of emails from a gridview 2 31
C# LINQ query question 11 33
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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