編集可能なdatagridviewがあります。その下にテキストボックスがあります。実行時にグリッドビューに値を入力し、その下のテキストボックスに合計を計算しています。問題は、グリッドビューで値を変更するたびに、テキストボックスが前の値を保持し、新しい値を前の値に追加することです。古い値を追加したくありません。私はこのコードを書きました
private void grdPurchase_CellEndEdit_1(object sender, DataGridViewCellEventArgs e)
{
try
{
//this.grdPurchase.Refresh();
(grdPurchase.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() != "")
string value = grdPurchase.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (e.ColumnIndex == 4)
{
float val = float.Parse(value);
total = val;
if (vapasi1 == "Yes")
{
if((e.r
vtot += total;
txt_forvapasitotal.Text = vtot.ToString();
float vapsitot = float.Parse(txt_forvapasitotal.Text);
float vapsicalculate = (vapsitot * a);
float tax = vapsicalculate / 100;
float with_vapasi = vtot + tax;
txt_withvapasi.Text = Convert.ToString(with_vapasi);
}
else
{
nvtot += total;
txt_withoutvapasitot.Text = nvtot.ToString();
}
txt_vapasiincludedtot.Text = (float.Parse(txt_withvapasi.Text) + float.Parse(txt_withoutvapasitot.Text)).ToString();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}