Dim SUM As Double = 0
Try
For i As Integer = 0 To DataGridView1.RowCount - 1
Sum += (DataGridView1.Rows(i).Cells("Qty").Value)
Next
Catch ex As Exception
End Try
' Display SUM in to a LABEL
Me.lblQty.Text = SUM.ToString
or:
How can I get sum of total values from cells in DataGridView? I want it to look like this
Column1 Column2 Column3 Column4
String ---- String ---- String ---- 10
String ---- String ---- String ---- 7
String ---- String ---- String ---- 3
String ---- String ---- String ---- 5
I want to get number 25 (Sum from Column4).
Nguồn: Sharecode.vn