Form2 location in relation to Form1

DiverDan

Well-known member
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
User Rank
*Experts*
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
 
Youll need a reference of Form1 inside of Form2 or you can pass in Form1s Location and Size values to Form2. From that, youll have to manually set Form2s Location based on the values.

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

Note: Above is untested but looks right

-nerseus
 
Back
Top