Transfer values between different forms

Source: Internet
Author: User

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 ();}}    }

Related Article

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.