效果描述:
有三個窗體然後順序分別是
(1)點擊第一個窗體中的按鈕彈出第二個窗體,隱藏第一個窗體
(2)第二個窗體到一定時間彈出第三個窗體
(3)點擊第三個窗體的按鈕關閉第三個和第二個窗體,彈出第一個窗體
From1
代碼如下:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 打開form2隱藏form1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.fatherForm = this;
f.Show();
this.Hide();
}
}
}
Form2
代碼如下:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public Form1 fatherForm;
private void 打開from3_Click(object sender, EventArgs e)
{
Form3 f = new Form3();
f.fatherForm = this;
f.Show();
}
}
}
Form3
代碼如下:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
public Form2 fatherForm;
private void 關閉form3from2顯示from1_Click(object sender, EventArgs e)
{
fatherForm.fatherForm.Show();
fatherForm.Close();
this.Close();
}
}
}