C#跨窗體操作(引用傳遞) 實(shí)例代碼
效果描述:
有三個(gè)窗體然后順序分別是
(1)點(diǎn)擊第一個(gè)窗體中的按鈕彈出第二個(gè)窗體,隱藏第一個(gè)窗體
(2)第二個(gè)窗體到一定時(shí)間彈出第三個(gè)窗體
(3)點(diǎn)擊第三個(gè)窗體的按鈕關(guān)閉第三個(gè)和第二個(gè)窗體,彈出第一個(gè)窗體
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 關(guān)閉form3from2顯示from1_Click(object sender, EventArgs e)
{
fatherForm.fatherForm.Show();
fatherForm.Close();
this.Close();
}
}
}
相關(guān)文章
c#橋接模式(bridge結(jié)構(gòu)模式)用法實(shí)例
這篇文章主要介紹了c#橋接模式(bridge結(jié)構(gòu)模式)用法,較為詳細(xì)的分析了橋接模式的原理與用法實(shí)例,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12讀寫XML文件的內(nèi)容并將其顯示在ListView控件上的方法
下面小編就為大家?guī)硪黄x寫XML文件的內(nèi)容并將其顯示在ListView控件上的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02C#winform中數(shù)據(jù)庫(kù)綁定DataGrid的實(shí)現(xiàn)
本文主要介紹了C#winform中數(shù)據(jù)庫(kù)綁定DataGrid的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05Unity實(shí)現(xiàn)多平臺(tái)二維碼掃描
這篇文章主要為大家詳細(xì)介紹了Unity實(shí)現(xiàn)多平臺(tái)二維碼掃描,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-07-07