andrewmanuja
Well-known member
- Joined
- May 30, 2019
- Messages
- 75
- Programming Experience
- Beginner
Hi All,
I got a dataGridView which got the following fields,
orderID, drugID, requestquantity and balancequantity
MyDataGridView looks like below;
The above said data is loaded from a SQL DB table.
What I want to perform is, whenever a user enter a value in to the "Issue Quantity" column, the dataGridView's "Balance Quantity" should get automatically adjusted.
For an example, if I enter 20 against Drug ID "10", I should be able to see the respective"Issue Quantity" as "40".
Similarly , I want to see the change for the Balance quantity for all the other products in the DataGridView too.
I tried something like below;
However, this does not give me the desired output. For an example, If I keep on changing the "Issue Quantity" value, and click somewhere else, it will keep on dropping the "Balance Quantity" value.
Thank you in advance.
Kind regards,
Andrew
I got a dataGridView which got the following fields,
orderID, drugID, requestquantity and balancequantity
MyDataGridView looks like below;
The above said data is loaded from a SQL DB table.
What I want to perform is, whenever a user enter a value in to the "Issue Quantity" column, the dataGridView's "Balance Quantity" should get automatically adjusted.
For an example, if I enter 20 against Drug ID "10", I should be able to see the respective"Issue Quantity" as "40".
Similarly , I want to see the change for the Balance quantity for all the other products in the DataGridView too.
I tried something like below;
C#:
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Cells[dataGridView1.Columns["balancequantity"].Index].Value = (Convert.ToInt32(row.Cells[dataGridView1.Columns["balancequantity"].Index].Value) - Convert.ToInt32(row.Cells[dataGridView1.Columns["issuequantity"].Index].Value));
}
}
However, this does not give me the desired output. For an example, If I keep on changing the "Issue Quantity" value, and click somewhere else, it will keep on dropping the "Balance Quantity" value.
Thank you in advance.
Kind regards,
Andrew
Last edited by a moderator: