In window form we want auto fill calculated amount in my last cell.We take value rate and quantity from other cell same form.In this case 1st create Grid CellEnter event and put below code.
private void dgv_test_CellEnter(object sender, DataGridViewCellEventArgs e)
{
double SalesQty;
double salesRate;
double amount;
int i = dgv_test.CurrentRow.Index;
if (Convert.ToString( dgv_test .Rows[i].Cells[0].Value).Length == 0)
{
SalesQty = 0;
}
else
{
SalesQty = Convert.ToInt32(dgv_sales.Rows[i].Cells[0].Value);
}
if (Convert.ToString( dgv_test .Rows[i].Cells[1].Value).Length == 0)
{
salesRate = 0;
}
else
{
salesRate = Convert.ToInt32( dgv_test .Rows[i].Cells[1].Value);
}
amount = SalesQty * salesRate;
dgv_test .Rows[i].Cells[2].Value = amount;
}
No comments :
Post a Comment