Mada Black

Mada Black

  • NA
  • 67
  • 3.1k

Calculate Sum Total in Column Gridview by Key Enter

Nov 19 2020 6:11 PM
Please i need your help
I have 3 columns .. column Price ( 4 ) , columns Quantite ( 5 ) and column Total ( 6 ) .. I want by Key Press when i update cell in column Quantity ( 5 ) then the sum changes automatically in columns Total ( 6 ) .. i tried like this but it does not work ..
Private Sub GridView1_KeyDown(sender As Object, e As KeyEventArgs) Handles GridView1.KeyDown
If e.KeyCode = System.Windows.Forms.Keys.Enter Then
Auto_Row_Calculation()
End If
End Sub
Private Sub Auto_Row_Calculation()
Dim GridQuantite As Integer = 0
Dim GridPrice As Decimal = 0.0
Dim GridTotal As Decimal = 0.0
For I As Integer = 0 To GridView1.RowCount - 1
GridPrice = Me.GridView1.GetRowCellValue(I, GridView1.Columns(4)).ToString
GridQuantite = Me.GridView1.GetRowCellValue(I, GridView1.Columns(5)).ToString
GridTotal = Val(GridPrice) * Val(GridQuantite)
Me.GridView1.SetRowCellValue(I, 6, GridTotal.ToString)
Next
End Ssub
Thank you in advance for help

Answers (4)