I have a DataTable, bound to a DataGridView for data entry. As a row is entered, I'd like to populate a label with the running total of the "Total Cost" column.
I've found documentation and have code that is working, BUT, it seems that the compute method is always one row behind. User enters row(0), the label does not populate, then after user enters rows(2), going into Row(3), the label.text is populated with the total of Row(0) only.
When I call DataTable.AcceptChanges, the datatable is cleared.
Here is code I'm using:
Private Sub DG_Labor_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DG_Labor.CellValueChanged
If e.ColumnIndex = 9 Then
Catch ex As Exception
MsgBox("Couldn't Calculate the total Labor Sum")
Private Sub Calc_Labor_Totals()
Dim result = dt_LaborInfo.Compute("sum(Labor_Total_Cost)", "")
Me.lbl_Labor_Totals.Text = result.ToString()