title: Error adding panel to usercontrol: Object reference not set to an instance of an object
body: <p>I have a problem. I am trying to access a panel in a user control.When I access it in a form it works. Earlier on I did this.</p>
  <p>I accessed a panel in a form from a user control and it worked. Below is the code I used:</p>
  <pre><code>Form1 form = Application.OpenForms.OfType&lt;Form1&gt;().FirstOrDefault();
              form.Panel1.Controls.Clear();
              ManageControl user = new ManageControl();
              form.Panel1.Controls.Add(user);
  </code></pre>
  <p>But when I try to use the very same concept in a user control it does not work.</p>
  <p>It throws a null error: <code>Object reference not set to an instance of an object.</code></p>
  <p>Below is the code:</p>
  <pre><code>//this is in ManageControl.cs
  public Panel Panel2
          {
              get { return panelmanage; }
          } 
  </code></pre>
  <p>//this is in another userControl.Trying to access panelImage</p>
  <pre><code> ManageControl form = Application.OpenForms.OfType&lt;ManageControl&gt;().FirstOrDefault();
              form.Panel2.Controls.Clear();//it throws the error here
              ReportControl user = new ReportControl();
              form.Panel2.Controls.Add(user);
  </code></pre>
  <p>What am I doing wrong because I am using the same concept?</p>
  <p><strong>EDIT</strong>:</p>
  <p>This is my ManageControl.cs</p>
  <pre><code> public partial class ManageControl : UserControl
      {
  
          public ManageControl()
          {
              InitializeComponent();
              
          }
  
          public Panel Panel2
          {
              get { return panelmanage; }
             
          }
  </code></pre>
  <p>This is how I try to access it in BookingListControl</p>
  <pre><code>public partial class BookingListControl : UserControl
      {
          ManageControl form = Application.OpenForms.OfType&lt;ManageControl&gt;().FirstOrDefault();
          public BookingListControl()
          {
              InitializeComponent();
          }
  
          private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
          {
              ManageControl form = Application.OpenForms.OfType&lt;ManageControl&gt;().FirstOrDefault();
           
              ReportControl user = new ReportControl();
              form.Panel2.Controls.Add(user);
          }
  </code></pre>