I want to detect the cell value has been changed of a specific column.
My Datagridview name is DGV_Products
and it has 6 columns.
Product ID | Descriptions | Quantity | Unit Price | Discount | Amount
G 01 | Gallon #01 | 2 | 1850 | 100 | 3600
G 02 | Gallon #02 | 1 | 1850 | 50 | 1800
I want to fire some code only when the Quantity column
cell value changed not when the discount column
value change. How can I fulfill my task? Currently the codes, what I have tried which is;
Private Sub DGV_Products_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_Products.CellValueChanged
If DGV_Products.Rows.Count > 0 Then
Dim Quantity As Integer = CInt(DGV_Products.CurrentRow.Cells(2).Value)
Dim UnitProce As Integer = CInt(DGV_Products.CurrentRow.Cells(3).Value)
Dim DiscountPrice As Integer = CInt(DGV_Products.CurrentRow.Cells(4).Value)
Dim TotalDiscount As Integer = DiscountPrice * Quantity
Dim Amount As Integer = UnitProce * Quantity
Amount = Amount - TotalDiscount
DGV_Products.CurrentRow.Cells(4).Value = TotalDiscount
DGV_Products.CurrentRow.Cells(5).Value = Amount
RefreshTotal()
End If
End Sub
*Apologies for bad english.