You are going through the entire DataGridView so you are probably just picking up the last "Row" which is where the user can add a row.
Try stepping through your code to confirm this, or set val to a strange number at the start of the loop to prove the point e.g.
private void metroGrid1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
int val = -99;
foreach (DataGridViewRow row in metroGrid1.Rows)
{
val = Convert.ToInt32(row.Cells["quantity"].Value);
}
totPenTxt.Text = val.ToString();
}
Learn how to debug your own code by reading this article -
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]