Form2 location in relation to Form1

DiverDan

Contributor
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
When Form2 is called from Form1 how can the starting position of Form2 be in reference to the location of Form1....ie. Form2 starts on the right-hand side of Form1?

Thanks :D
 
You'll need a reference of Form1 inside of Form2 or you can pass in Form1's Location and Size values to Form2. From that, you'll have to manually set Form2's Location based on the values.

For example:
Code:
// In Form2's constructor, after InitializeComponent
// Assumes "f" is a Form variable that references an instance of Form1, probably passed in through Form2's constructor
this.Location = new Point(f.Left + f.Width, f.Top);

Note: Above is untested but looks right

-nerseus
 
Back
Top