I want to place two forms next to each other in C #

I have one form that opens up another form.

What I want to do is position the newly opened form on the right (right) in an already visible form.

So I need to put the new form where the current form ends (correct me if not).

So I will need to do something like:

newform.Left = this.endposition.right; 

The endpos property is what I just compiled (pseudocode).

How to get the end position on the right side of the current form?

EDIT

I tried several solutions, but so far none of them have worked.

I always get the same result:

Why is this happening http://s1.postimage.org/f4fsbc6pa/why_o_why.png

I tried the following codes:

 newform.Left = this.Right + SystemInformation.BorderSize.Width; newform.Left = this.Right + (SystemInformation.BorderSize.Width * 2); newform.SetDesktopLocation(this.Location.X + this.Size.Width, this.Location.Y); 

Eclyps19 suggested just adding a few pixels to accommodate the new shape, although I'm not sure if the border will be the same for each system.

+7
source share
3 answers

This works for me:

  Form1 nForm = new Form1(); nForm.Show(); nForm.SetDesktopLocation(this.Location.X + this.Size.Width, this.Location.Y); 
+9
source

Try

 newform.Left = oldform.Right + SystemInformation.BorderSize.Width; 

This should add the width (in pixels) of the border to the oldform.Right value. You can replace (or add) SystemInformation.BorderSize.Width with any integer that you would like to your liking.

+3
source

Your code works fine, but you just have to use it AFTER your new Form.Show () method.

0
source

All Articles