Form2 frm2 = new Form2();
private void MoveProc()
{
frm2.StartPosition = FormStartPosition.CenterParent;
frm2.Left = this.Left + panel1.Left;
frm2.Top = this.Top + panel1.Top;
}
public Form1()
{
InitializeComponent();
MoveProc();
this.AddOwnedForm(frm2);
frm2.Show();
}
private void Form1_Move(object sender, EventArgs e)
{
MoveProc();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.StartPosition = FormStartPosition.CenterParent;
frm2.ShowDialog();
}
条件:
- 缩略图显示包含跟随的窗体
- 跟随的窗体只在主窗体的最上面
- 主窗体能使用ShowDialog()使用其他窗体
FORM1
FORM2
附件列表