I have one form which opens another form.
What I want to do is position the newly opened form right next (on the right side) to the already visible form.
So I need to position the new form to where the current form ends (correct me if wrong).
So I will need to do something like:
newform.Left = this.endposition.right;
The endposition property is something I just made up (pseudo code).
How to get the end position on the right side of the current form?
EDIT
I've tried several solutions but until now none of them worked.
I always get the same result:
I've 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 to just manually add some pixels to position the new form, although I'm not sure whether the border will be the same on every system.
This works for me:
Form1 nForm = new Form1();
nForm.Show();
nForm.SetDesktopLocation(this.Location.X + this.Size.Width, this.Location.Y);
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 to) SystemInformation.BorderSize.Width with any integer you'd like to fit your liking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With