31. Interaction between Windows
The interaction between Windows is mainly in 3 ways:
A. Properties. The popup window passes the data to the parent window through a read-write property, accepting the parent window's data.
B. Methods. The popup window passes data to the parent window through a constructor or method, accepting the parent window's data.
C. Events. The popup window notifies the parent window through the event that there is data that needs to be interacted with.
Interact with the data between the real windows of the property.
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Windows.Forms;
Namespace WindowsFormsApplication17
{
public partial class Form2:form
{
private string _strname;
public string StrName
{
Get
{
return this._strname;
}
Set
{
This._strname = value;
}
}
Public Form2 ()
{
InitializeComponent ();
}
private void Form2_load (object sender, EventArgs e)
{
This.label1.Text = "Welcome You" + This.strname + "Classmate!" ";
}
}
}
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6B/62/wKioL1Ush3Wy0m_WAADzYLoq9sQ566.jpg "title=" Mr8bdbr4cuniv0} ' by[3 (vs.png "alt=" Wkiol1ush3wy0m_waadzyloq9sq566.jpg "/>
The window's constructors enable interaction between windows.
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Windows.Forms;
Namespace WindowsFormsApplication18
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}
private void Button1_Click (object sender, EventArgs e)
{
string strName = This.textBox2.Text;
Form2 form = new Form2 (strName);
Form. Show ();
}
private void Button2_Click (object sender, EventArgs e)
{
This. Close ();
}
}
}
The effect is the same as above.
This article from "Very blog" blog, reproduced please contact the author!
C # Self-study Road 31