请我想将一列中的条目与另一列条目相乘,结果将在DataGridView
.
请问这些有什么问题:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int crsUn, cmb;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (int.TryParse(dataGridView1.Rows[i].Cells[2].Value.ToString(), out crsUn) && int.TryParse(dataGridView1.Rows[i].Cells[4].Value.ToString(), out cmb))
{
int gp = crsUn * cmb;
dataGridView1.Rows[i].Cells[5].Value = gp.ToString();
}
}
}