title: Passing a value from one form to another form
body: <p>I have two forms named <code>form1</code> and <code>form2</code>:</p>
  
  <ul>
  <li><code>form1</code> is made of a <code>label</code> and a <code>button</code>. </li>
  <li><code>form2</code> is made of a <code>textBox</code> and a <code>button</code></li>
  </ul>
  
  <p>When I click the <code>form1</code> button, this will show up <code>form2</code>. Any inputs in <code>textBox</code> should be written back to <code>form1.label</code> once I hit the button in <code>form2</code>.<br>
  I have the code below but it doesn't work.</p>
  
  <pre><code>// Code from Form 1
  public partial class Form1 : Form
  {
      public void PassValue(string strValue)
      {
          label1.Text = strValue;
      }
      public Form1()
      {
          InitializeComponent();
      }
      private void button1_Click(object sender, EventArgs e)
      {
          Form2 objForm2 = new Form2();
          objForm2.Show();
      }
  
  }
  
  // Code From Form 2
  
  public partial class Form2 : Form
  {
      public Form2()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          Form1 objForm1 = new Form1();
          objForm1.PassValue(textBox1.Text);
          this.Close();
      }
  }
  </code></pre>
  
  <p>And a screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/Ga9TX.jpg" alt="Application screenshot"></p>
  
  <p>How can I realize that?</p>