Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show another form adjacent to the one its spawned from C#

Tags:

c#

.net

winforms

How would it be possible to spawn a new form e.g. Form2 from Form1, but make sure Form2 is adjacent to Form1, for example:

enter image description here

like image 860
Mike Avatar asked Jan 15 '12 16:01

Mike


1 Answers

Something like:

// button click handler method

Form2 child = new Form2();
child.Location = new Point(this.Location.X + this.Width, 
                           this.location.Y);
child.Show();

Take the X coordinate of the location of the current form object and add to it the width of the form, thus obtaining the X coordinate of the new form. The Y coordinate stays the same.

like image 140
Tudor Avatar answered Sep 30 '22 05:09

Tudor