//点击form1上button1隐藏form1,显示form2 private void button1_Click(object sender, EventArgs e) { this.Hide(); Form2 fm2=new Form2(0; fm2.Show(); } //关闭fomr2,显示form1 private void showfm1(object sender, FormClosingEventArgs e) { Form1 fm1 = new Form1(); fm1.Show(); } //form1 code private void button1_Click(object sender, EventArgs e) { this.Hide(); Form frm = new Form2(this); frm.Show(); } //form2 code private Form m_frm; public Form2(Form frm) { InitializeComponent(); m_frm = frm; } private void showfm1(object sender, FormClosingEventArgs e) { if (m_frm != null) { m_frm.Show(); } } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form frm = new Form2(this); //定义新窗体使用当前窗体的坐标 frm.SetDesktopLocation(this.DesktopLocation.X,this.DesktopLocation.Y); frm.Show(); } 本文出自 “” 博客,请务必保留此出处 |