对于每个语句,我需要一些帮助,基本上,当用户编辑单元格中的值时,我的 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;
}