I created some code to sum two columns of a datagrid.
Public Sub totalhours()
'Calculated the Total Column for time worked
Dim TotalTime As Double
Dim QtyPacked As Integer
Dim TimeEach As Integer
'Computes the Total hours cell in the datagrid
Try
If Not IsDBNull(dgPacking.Item(dgPacking.CurrentRowIndex, 3)) _
And Not IsDBNull(dgPacking.Item(dgPacking.CurrentRowIndex, 2)) Then
'dgPacking.Item(dgPacking.CurrentRowIndex, 2) = TDBTimeEach.Value
'dgPacking.Item(dgPacking.CurrentRowIndex, 3) = TDBDQtyPacked.Value
TimeEach = dgPacking.Item(dgPacking.CurrentRowIndex, 2)
QtyPacked = dgPacking.Item(dgPacking.CurrentRowIndex, 3)
TotalTime = (QtyPacked * TimeEach) / 60
dgPacking.Item(dgPacking.CurrentRowIndex, 4) = Math.Round(TotalTime, 2)
btnSave.Enabled = True
End If
Catch ex As Exception
Throw ex
MsgBox(ex.Message)
End Try
End Sub
I've been working with Datagrid alot, if you have any questions just make sure you clearly explain what you want.
Hook it with at star it this helps.