Now we will introduce you to the simplest cross-form operation.
The WinForm is a class, and the C # class is a reference type. So we should be able to pass the WinForm class, so we can not perform the operation?
Effect description:
There are three forms and the order is
(1) click the button in the first form to bring up the second form and hide the first form.
(2) The third form is displayed from the second form to a certain time.
(3) click the button of the third form to close the third and second forms. The first form is displayed.
From1
Using System;
Using System. Windows. Forms;
Namespace WindowsFormsApplication1
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void open form2 hide 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 open 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 disable form3from2 display from1_Click (object sender, EventArgs e)
{
FatherForm. fatherForm. Show ();
FatherForm. Close ();
This. Close ();
}
}
}
From tu jiankai's column