c#中如何让一个窗体在另一个旁边

【转载】

当点击窗体1的按钮,窗体2就出现在窗体1的左边:

窗体1
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2(this.Location.X+this.Width,this.Location.Y);
//窗体2出现在左还是右,在new Form2()输入参数

f.Show();
}
}
窗体2
public partial class Form2 : Form
{
int x = 0; int y = 0;
public Form2(int x,int y)
{
InitializeComponent();
this.x = x;
this.y = y;

}
private void Form2_Load(object sender, EventArgs e)
{
this.Location = new Point(x, y);
}
}
原文地址:https://www.cnblogs.com/masonchi/p/3446029.html