title: Read a datagridview in another class than main one
body: <p>I have a form with datagridview and I want to use it in another class, to export the data from it.</p>
  
  <p>I have this function for exporting:</p>
  
  <pre><code>public void exportWebsite(DataGridView gridIn, string outputFile)
  {
      //test to see if the DataGridView has any rows
      if (gridIn.RowCount &gt; 0)
      {
          string value = "";
          DataGridViewRow dr = new DataGridViewRow();
          StreamWriter swOut = new StreamWriter(outputFile);
  
          swOut.Write(gridIn.Columns[9].HeaderText);
  
          swOut.WriteLine();
  
          //write DataGridView rows to csv
          for (int j = 0; j &lt;= gridIn.Rows.Count - 1; j++)
          {
              if (j &gt; 0)
              {
                  swOut.WriteLine();
              }
  
              dr = gridIn.Rows[j];
  
  
              if (dr.Cells[9].Value.ToString() == " " || dr.Cells[9].Value.ToString() == null || dr.Cells[9].Value.ToString() == "")
              {
                  value = " ";
              }
              else
              {
                  value = dr.Cells[9].Value.ToString();
              }
              swOut.Write(value);
  
          }
          swOut.Close();
      }
  }
  </code></pre>
  
  <p>That is in the same class of the Form, but I want to do the exporting from an "external" class, different than the main one. How can I call the datagridview there? I tried using perimeter "DataGridView dgv" in the class definition, but it doesn't exist such thing.</p>
  
  <p>So, my question is how can I pass the datagridview to another class other than the main one?</p>