我有一种形式可以打开另一种形式。
我想要做的是将新打开的表单放在已经可见的表单旁边(右侧)。
所以我需要将新表单定位到当前表单结束的位置(如果错误,请纠正我)。
所以我需要做一些类似的事情:
newform.Left = this.endposition.right;
endposition 属性是我刚刚编写的(伪代码)。
如何获取当前表单右侧的结束位置?
编辑
我已经尝试了几种解决方案,但直到现在它们都没有奏效。
我总是得到相同的结果:
我试过以下代码:
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 建议手动添加一些像素来定位新表单,尽管我不确定每个系统上的边框是否相同。
最佳答案
这对我有用:
Form1 nForm = new Form1();
nForm.Show();
nForm.SetDesktopLocation(this.Location.X + this.Size.Width, this.Location.Y);
关于c# - 我想在 C# 中将两个表单并排放置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7208564/