各ステートメントのヘルプが必要です。基本的に、ユーザーがセル内の値を編集すると、foreachがこれをデータグリッド内のすべてのセルに適用し、それらすべての値を変更します。foreachステートメントが機能する必要があります。データグリッドを反復処理しますが、編集された選択された行のみを変更しますが、すべての行のカウントを更新しているように見えますが、これは現在の行のみである必要があります
foreach (DataGridViewRow row in dgvDetials.Rows) //loop through each of the results
{
string scrapDate, scrapShift, PartCode;
scrapDate = dtpInspectionDate.Value.ToString("MM/dd/yyyy");
scrapShift = cbShift.Text;
PartCode = row.Cells[0].Value.ToString();
//define each of the counts
int qtyInspCount = SQLMethods.CountQtyInspTotal(scrapDate, scrapShift, area, PartCode);
int scrapCount = SQLMethods.CountScrapReworkTotal(scrapDate, scrapShift, area, PartCode, "S");
int reworkCount = SQLMethods.CountScrapReworkTotal(scrapDate, scrapShift, area, PartCode, "R");
//populate each of the counts cells
row.Cells[2].Value = 0;
row.Cells[5].Value = qtyInspCount;
row.Cells[3].Value = scrapCount;
row.Cells[4].Value = reworkCount;
}