title: Simplify the creation of MDI child Forms based on their Type
body: <p>I have an MDI Application and each child Form needs to be initialized using the same operations:</p>
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      frmClient useform=new frmClient();
      useform.MdiParent=this;
      useform.Text=this.Text+&quot; - &quot;+useform.Text;
      useform.Show();
  }
  </code></pre>
  <p>I do this for about 5 or 6 different Forms. To avoid repetitions, I have a  method to create instances of child Forms:</p>
  <pre><code>private void OpenFocus&lt;frmType&gt;()
  {
      //iterate child forms and if this type is found, set it as focused and return true
      if (IsFormOpen(typeof(frmType)))
      {
          return;
      }
  
      var useform = new Form(); 
      switch (typeof(frmType).Name)
      {
          case &quot;frmCompany&quot;:
              useform = new frmCompany();
              break;
          case &quot;frmClients&quot;:
              useform = new frmClients();
              break;
          /*
              a whole bunch more forms
              ...
          */
          default:
              return;
      }
      useform.MdiParent=this;
      useform.Text=this.Text+&quot; - &quot;+useform.Text;
      useform.Show();
  }
  </code></pre>
  <p>Called like:</p>
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      OpenFocus&lt;frmCompany&gt;();
  }
  private void button2_Click(object sender, EventArgs e)
  {
      OpenFocus&lt;frmClients&gt;();
  }
  </code></pre>
  <p>I have tried</p>
  <pre><code>var useform=Activator.CreateInstance&lt;frmType&gt;();
  </code></pre>
  <p>but it is extremely slow, so am avoiding it.</p>
  <p>Any suggestions to improve this? It doesn't <em>feel</em> right.</p>