title: How to write a text file from a .NET DataGridView control cell values?
body: <p>I have the following code that should loop through all the rows in my <code>DataGridView</code>, and write all their cell values to a text file.<br>
  However, it outputs all the rows, but only the first cell of each one, and not the other three cells.</p>
  
  <pre><code>string file_name = "C:\\test1.txt";
  
  var objWriter = new System.IO.StreamWriter(file_name);
  
  int count = dgv.Rows.Count;
  
  for (int row = 0; row &lt; count; row++)
  {
      objWriter.WriteLine(dgv.Rows[row].Cells[0].Value.ToString());
  }
  
  objWriter.Close();
  </code></pre>