Solved

Positioning form

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

772 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