C# 窗体之间的链接语句怎么写啊?

来源:百度知道 编辑:UC知道 时间:2024/06/17 07:50:05
我记得是This.hide();This.show();什么的,比如说有两个窗体Form1和Form2怎样让1出现后点进按钮后2出现1隐藏呢?

新建一个windows窗体,名字叫Form2,对吧?

在form1的按钮里面写:
Form2 f2 = new Form2(); //一定要这句话,生成一个form2的对象。操作的只能是对象。
f2.Show(); //用f2.visable=ture; 也行
this.Hide();

private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
this.Hide();
}

实例化另外一个窗体:Form2 f2 = new Form2();
显示实例化窗体: f2.Show();
隐藏本窗体: this.visable=false