title: Accessing main form objects in other .cs files
body: <p>It's easy to access sub-window's objects from main file because we must create the sub window anyway. So there's something like this:</p>
  
  <pre><code>SubForm subform = new SubForm();
  if (subform.ShowDialog() == DialogResult.OK)
  {
      text = subform.textBox1.Text; 
      //...
  }
  </code></pre>
  
  <p>But I have some troubles with editing a combobox (placed inside main form) by a sub-cs file. I can't simply create a new main window. I've edited Program.cs file:</p>
  
  <pre><code>static class Program
      {
          public static MainForm mainform; //main window reference
          /// &lt;summary&gt;
          /// The main entry point for the application.
          /// &lt;/summary&gt;
          [STAThread]
          static void Main()
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(mainform = new MainForm());
          }
      }
  </code></pre>
  
  <p>Now I can access the combobox:</p>
  
  <pre><code>Program.mainform.comboCurves.Items.Add("test");
  </code></pre>
  
  <p>Is it any better solution for this?</p>