title: How to get all values from a column in a DataGridView
body: <p>You see, I'm trying to add the quantity if the item name already exists in the DataGridView. So what I did was made a for loop to check each row in the DataGridView. What it did was just add more rows. </p>
  
  <pre><code>for (int x = 0; x &lt; dataGridView.Rows.Count; x++)
  {
      if (dataGridView.Rows[x].Cells[1].Value.ToString() == dataTable.Rows[0][2].ToString())
      {
          dataGridView.Rows[x].Cells[0].Value = int.Parse(dataGridView.Rows[x].Cells[0].Value.ToString()) + 1;
          dataGridView.Rows[x].Cells[2].Value = Convert.ToDecimal(dataTable.Rows[0][4].ToString()) * Convert.ToDecimal(dataGridView.Rows[x].Cells[0].Value.ToString());
      }
      else
      {
          quantity = 1;
          dataGridView.Rows.Add(quantity, dataTable.Rows[0][2], dataTable.Rows[0][4]);
      }
  }
  </code></pre>