现在有主窗体Form1和窗体Form2,主窗体上有个btn,点击进入Form2的同时Form1消失,代码该怎么写?
static void Main()
{
Form1 form1 = new Form1 ();
Application.Run(form1);
}
private void button1_Click(object sender, System.EventArgs e)
{
Form2 form2 = new Form2 ();
form2.Show ();
//可是怎么在这里实现让form1消失呢?
}
相关推荐
C#中主窗体Panel中加载其他多个窗体Panel控件
提供了一个C#中主窗体Panel中加载其他多个窗体Panel控件的办法
winForm中主窗体Form获取弹出窗体的中值
winForm中主窗体Form获取弹出窗体的中值
Form2调用Form1控件的解决方案
Q:Form1上一个Button点击后弹出新窗口Form2,在新窗口点击Button如何控制Form1中的某些控件? A:用委托。一个简单可行的办法用ref.下面是个小例子: 在Form1的button1_Click里写: private void button1_Click(object sender, EventArgs e) { this.button1.Enabled = false; Form2 f2 = new Form2(ref button1); f2.Show(); } Form2里这样写: public Button button; public Form2(ref Button button) { this.button = button; InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.button.Enabled = true; }
Delphi7隐藏主窗体同时不出现在任务栏
Delphi7隐藏主窗体同时不出现在任务栏
C#传递主窗体句柄并在子窗体调用其函数改变其控件的例子
本程序是完整的项目文件,在VS2008下运行成功,程序功能:通过传递主窗体句柄,然后打开子窗体,在子窗体中可对主窗体的控件或函数进行操作,改变其控件属性 ,调用主窗体的函数,(注:在调用前要修改主窗体被调用控件或函数的属性为PUBLIC)


