我有两种形式:Form1 和 Form2。Form1 有 button1,Form2 有 button2。项目运行时,显示Form1,点击button1,显示Form2,隐藏form1。如果我点击 button2 那么 Form1 是可见的并且 Form2 是关闭的!
表格1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 fo = new Form2();
fo.Visible = true;
}
}
表格2:
公共部分类 Form2 : Form { public Form2() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Visible = true;
this.Close();
}
}