title: Passing values between a class and a form
body: <p>I'm pretty new to C# - but it all went quite well - to this point.</p>
  
  <p>I start with a form and a class which does most of the work (non static and in the program part). I instantiate an object of the class in form 1 and do a log in.</p>
  
  <p>Then I switch over to the next form, form2. Actually, the the class does that. I have a method there, that contains the line:</p>
  
  <pre><code>this.f2 = new Form2();
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>f2.Show();
  </code></pre>
  
  <p>f2 is a class member of the type Form2 - and all just works fine - up to this point.</p>
  
  <p>This Form2 just consists of a big text box in which I want to display network events. The event handler works just fine - but the reference to the form just doesn't seem to work. If I do</p>
  
  <pre><code>f2.tetBox1.Text = "Some text";
  </code></pre>
  
  <p>it just won't change the the text in the text box.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>Here is a more detailed description of what I'm doing:</p>
  
  <p><code>Form1</code> passes some log in information to <code>myProg</code>, being an instance of <code>MyClass</code>. If the login was successful, Form1 calls <code>myProg.makeForm();</code></p>
  
  <p>This is what the method in MyClass looks like:</p>
  
  <pre><code>public void makeForm() {
              this.f2 = new Form2();
              f2.Show();
              this.sendString("start f2");
  }
  </code></pre>
  
  <p>This is <code>MyClass.sendString()</code>:</p>
  
  <pre><code>private void sendString(string text) {
              SystemSounds.Beep.Play();
              this.f2.setTextBox(text);
  }
  </code></pre>
  
  <p>This calls, as you see, <code>setTextBox()</code> of <code>Form2</code> - which I implemented as proposed here. The strange thing is, that up to this point all works well. The Form2 gets shown an textBox1 contains "start f2" - as expected. But when an event comes in, the text in textBox1 doesn't change. the beep get played all right - so the method sendString() gets called alright.</p>
  
  <p>One thing I have observed: If the beep line is placed after the call to  <code>this.f2.setTextBox(text);</code>, it doesn't get played if the method is called from the event handler. </p>
  
  <p><code>f2</code>, btw., is a private member of <code>MyClass</code>:</p>
  
  <pre><code>private Form2 f2;
  </code></pre>