title: Create a new instance of a control dynamically
body: <p>Ok so I have a form I'm building that's going to change it's interface by using custom controls.  What I'm trying to do is make several checks before a new control is created, like checking if one is already up.  I have everything working just fine but I can't seem to create the new control dynamically, without creating it before running the checks which defeats the purpose.</p>
  
  <p>The controls all implement an interface called ICustomControl and inherit from a MasterControl. Then I have a custom control called JobForm, and a button on the main form that calls the method like so: <code>Check_Controls(newJobForm)</code></p>
  
  <pre><code>JobForm newJobForm;
  
  private void Check_Controls(Control control) // Checks current controls to see if a new one can be opened 
  {
      bool currentControl = false;
  
      foreach (Control c in this.Controls)
      {
          if (c is ICustomControl &amp;&amp; c != masterControl)
              currentControl = true;
      }
  
      if (currentControl)
      {
          TimedMessageBox timedMessage = new TimedMessageBox("There is currently an open form.  Please close the current control before opening another.");
          timedMessage.ShowDialog();
      }
      else
      {
          Control c = (Control)Activator.CreateInstance(control.GetType());
          this.Controls.Add(c);
          Position_Control(c);
          c.Show();
      }
  }
  </code></pre>
  
  <p>I dont't want to create a new instance of the custom control like: <code>JobForm newJobForm = new JobForm();</code> before running the check method, I want to pass the reference to the check method and then have it create the new instance after it's checks are complete.  In this way no matter how many new custom controls I wind up adding to the application, all I have to do to set one up is create the reference variable, then for the button call the check method and pass it the reference.</p>
  
  <p>Anyone know how I can do this?</p>