title: Access TextBox from Static method in C#?
body: <p>I have 2 classes: MyForm and Database</p>
  
  <p>In MyForm I have a method to change a label text to show error:</p>
  
  <pre><code>public void printError(string text){
      label1.Text = text;
  }
  </code></pre>
  
  <p>My Database class needs to access that method too, so I make it static:</p>
  
  <pre><code>public static void printError(MyForm form, string text){
      form.label1.Text = text;
  }
  </code></pre>
  
  <p>Now the problem is, <strong>how do I call that method from Database class</strong>?</p>
  
  <p><a href="https://stackoverflow.com/questions/952023/in-c-sharp-net-how-does-one-access-a-control-from-a-static-method">This question</a> I found said that I need to pass MyForm into Database's contructor like this: </p>
  
  <pre><code>class MyForm : Form{
      Database db;
      public Form(){
          db = new Database(this);
      }
  }
  
  class Database{
      MyForm form;
      public Database(MyForm f){
          form = f;
      }
      ...
      //then I can access the printError like this
      MyForm.printError(form, "You got error");
  }
  </code></pre>
  
  <p>I tried that and it <strong>freezes the form</strong>. Any other solution?</p>
  
  <p>Thanks</p>