单击按钮主窗体打开子窗体,并隐藏本身
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form2 f = new Form2(this); f.Show(); } }
单击按钮子窗体关闭,并显示主窗体
public partial class Form2 : Form { private Form frm; public Form2(Form1 _frm) { this.frm = _frm; InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Close(); this.frm.Show(); } }
从网易博客(http://cxwstar.blog.163.com/blog/static/48468763201121402037629/)迁移,原发表于2011年3月14日.