我有一个datagridview
视图,其数量和价格的倍数值应显示在dgview.
的数量列中,我将粘贴到目前为止尝试过的代码。但是它会在以下行中抛出错误
dgvpricelist.Rows[i].Cells["totalamount"].Value = totalprice;
抛出的错误是"Stack overflow exception error"
。不知道为什么会抛出错误
public void totalcalculation()
{
if (dgvpricelist.Rows.Count > 1)
{
double TAmount = 0;
for (int i = 0; i < dgvpricelist.Rows.Count; i++)
{
int quantity = Convert.ToInt32(dgvpricelist.Rows[i].Cells["quantity"].Value);
double itemPrice = Convert.ToDouble(dgvpricelist.Rows[i].Cells["intpricelvl1"].Value);
totalprice = quantity * itemPrice;
dgvpricelist.Rows[i].Cells["totalamount"].Value = totalprice;
edittotalprice = Convert.ToDouble(dgvpricelist.Rows[i].Cells["totalamount"].Value);
TAmount += edittotalprice;
//txtboxtaxvalue.Text = tax.ToString();
//txtboxtotalvalue.Text = total.ToString();
//TAmount = edittotalprice;
}
int roundedtotal = (int)Math.Round(TAmount);
txtboxstotalvalue.Text = TAmount.ToString();
txtboxtotalvalue.Text = roundedtotal.ToString();
}
我可以知道实现目标的正确方法是什么?