C # Self-study Road 31

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.