title: Error message "An object reference is required for the non-static field, method or property."
body: <p>I am creating a program to access a database.</p>
  
  <p>The code that is causing me trouble is meant to open a new form when a button is pressed. It then gets data based on the selected values in a listbox on the main form and is needed to send that data to the second form to be placed in textboxes and labels.</p>
  
  <p>The problem I have, is that in order for the code to execute without throwing the Error </p>
  
  <blockquote>
    <p>"An object reference is required for the non-static field, method or property..."</p>
  </blockquote>
  
  <p>I must make the method in the secondary form static; however this prevents me from accessing the controls on the secondary form.</p>
  
  <p>Main Form Code Snippet:</p>
  
  <pre><code> private void MemView_Click(object sender, EventArgs e)
      {
          string selected = lstMember.SelectedItems[0].Text;
          //MessageBox.Show(selected);
          string[] data = P.selectMem(selected);
          MessageBox.Show(data[0]);
  
          MemForm mem = new MemForm(); //How to open a designed form
  
          mem.Show();  //Displays the addmem form
  
          MemForm.getData(data);
  
      }
  </code></pre>
  
  <p>Secondary Form Code Snippet:</p>
  
  <pre><code>public void getData(string[] Data)
      {
          int index = 0;
          bool loop = false;
          string text;
  
          while (loop == true)
          {
              if (index &lt; 10)
              { text = "tb0" + index.ToString(); }
              else
              { text = "tb" + index.ToString(); }
  
              index = index + 1;
          }
  
  
      }
  </code></pre>
  
  <p>My secondary code snippet is meant to use the loop to fill all the data into the textboxes without me having to manually write out each tb00.Text = data[] etc.
  I am unable to access the FindControls() method in C# most likely due to the need for a static method.
  The P class used in the Main Form performs the SQL code and is working fully.</p>
  
  <p>I've tried to give enough information for an answer, however if more is needed just ask in a comment I will try and provide more. :)</p>