public partial class Form1 : Form { // This is the text that will be entered in form2 public String form2text; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { // Show form2 Form2 objForm2 = new Form2(this); objForm2.ShowDialog(); // When form2 is closed, update the label text on form1 label1.Text = form2text; } } public partial class Form2 : Form { // This is the instance of Form1 that called form2 private Form1 form1caller; public Form2(Form1 form1caller) { InitializeComponent(); this.form1caller = form1caller; } private void button1_Click(object sender, EventArgs e) { // Pass the textBox value to form1 before closing form2 form1caller.form2text = textBox1.Text; this.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)