One: Before and after running, the implementation function takes the text value of the lable of the subform out to the lable text of the parent form
Two: All code
A, parent form
using system;using system.collections.generic;using system.componentmodel;using system.data;using System.drawing;using system.linq;using system.text;using system.windows.forms;namespace passV{public partial class Fo Rm1:form {public Form1 () {InitializeComponent (); }///<summary>//lable The text value of the subform to the text of the parent form's lable///</summary>//<para M name= "txt" ></param> private void Getlabletxt (string text) {this.label1.Text = text; }///<summary>///Open Subform///</summary>//<param name= "Sender" >< /param>//<param name= "E" ></param> private void button2_click (object sender, EventArgs e) {Son son = new son (); if (DialogResult.OK = = son. ShowDialog ()) {Getlabletxt (son. Text); }}}}
B, Subform
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;namespace passv{public partial class Son:form { private string text; public string Text { get {return Text;} set {text = value;} } Public Son () { InitializeComponent (); } <summary> //Confirm///</summary>//<param name= "sender" ></param>/ <param name= "E" ></param> private void Button1_Click (object sender, EventArgs e) { Text = Label1. Text; This. DialogResult = DialogResult.OK; This. Close ();}} }