110,536
社区成员
发帖
与我相关
我的任务
分享
private void form1_LocationChanged(object sender, EventArgs e)
{
this.Location = new Point(this.m_form1.Location.X + this.m_form1.Width, this.m_form1.Location.Y); //<---
}
public partial class Form2 : Form
{
private Form1 m_form1;
public Form2()
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.WindowState = FormWindowState.Normal;
}
private void Form2_Load(object sender, EventArgs e)
{
this.m_form1 = (Form1)this.Owner;
this.m_form1.LocationChanged += new EventHandler(form1_LocationChanged);
base.OnLoad(e);
}
private void form1_LocationChanged(object sender, EventArgs e)
{
this.Location = new Point(this.m_form1.Location.X + this.m_form1.Width, this.m_form1.Location.Y);
}
}
public partial class Form1 : Form
{
private Form2 m_form2;
public Form1()
{
InitializeComponent();
this.m_form2 = new Form2();
this.m_form2.Owner = this;
}
private void Form1_Load(object sender, EventArgs e)
{
this.m_form2.Location = new Point(this.Location.X + this.Width,this.Location.Y );
this.m_form2.Show();
base.OnLoad(e);
}
}