更新时间:2022-12-12 09:57:22
for (int i = 0; i <= dataGridView1.RowCount ; i++)
{
mark = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
unit = Convert.ToInt32(dataGridView1.CurrentRow.Cells[2].Value);
result += ( s1 * s);
}
但这段代码只计算第一行。
我如何更改行索引?
but this code calculate just first row.
how i change row index?
我解决了!
i solve it!
for (int i = 0; i < dataGridView1.RowCount ; i++)
{
mark = Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value);
unit = Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
sumunit += unit;
result += ( mark * unit);
}
result /= sumunit;
label2.Text = result.ToString();
}