title: How can I add a UserControl to a Panel on the main form?
body: <p>I am working on project winForm application. Am trying to add a UserControl to a Panel on the main Form.
  Here is what I did, I created a public static method on the Main Form so I can call it from anywhere without instantiating the main form.</p>
  
  <pre><code>public static void showUC(UserControl uc)
      {
          pnlContainer.Controls.Clear();
          GC.Collect();
          uc.Dock = DockStyle.Fill;
          pnlContainer.Controls.Add(uc);
      }
  </code></pre>
  
  <p>I am getting a compilation error "An object reference is required for a non-static field, method or property".</p>
  
  <p>If I create the method as non-static the compilation error will be gone but I won't be able to call it without creating object of the main form.</p>
  
  <p>What I want to achieve is to be able to open any UserControl inside the Panel 'pnlContainer' on my Main Form 'frmMain'.</p>
  
  <p>When the main form loads I want to calling the method without instantiating the main form again. For example</p>
  
  <pre><code>public static void showUC(UserControl uc)
  {
      pnlContainer.Controls.Clear();
      GC.Collect();
      uc.Dock = DockStyle.Fill;
      pnlContainer.Controls.Add(uc);
  }
  </code></pre>
  
  <p>I want to be calling this method like this</p>
  
  <pre><code>frmMain.showUC(new ucClientList);
  </code></pre>
  
  <p>From another class.</p>
  
  <p>Let me explain exactly what I want to achieve.
  I have a Form Control named 'frmMain' which contain a panel control named 'pnlContainer' and I want to be loading UserControl into it, I have UserControl1 and UserControl2.
  Now I run the program and the frmMain loads, I wants to add UserControl1 to the panel pnlContainer and I have a button inside the UserControl1 which is supposed to load UserControl2 into the same panel on the Main Form when I click on it. How do I implement this?</p>