Solved

Positioning form

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now