Each time a user changes a value in one of the editable columns within my DataGridView, it triggers a recalculation of up to 8 fields. This means the event CellValueChanged Event on the DataGridView will trigger more than 1 time.
I want to create a row in a DataSet.DataTable which will include the new values for all columns after the user has changed a value.
The issue I am having is that the code below creates a row for each column that has had its value changed due to the recalculated columns.
Private Sub PL_DGV_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles PL_DGV.CellValueChanged
If isLoaded Then
Dim grid_row As DataRow = Me.DataSet.PL.Rows(e.RowIndex)
Dim unsaved_row As DataRow = grid_row
Me.DataSet.PL_UnsavedChanges.ImportRow(unsaved_row)
unsaved_changes = True
End If
End Sub
How could I make it so that if a row already exists, it will just update the values within it each time?
There is no PrimaryKeys assigned to the DataTable within the DataSet, but there are 3 columns which would be used as unique values per row.
[UPDATE BASED ON COMMENTS]
With the code shown above what will happen is that the user will update a value in column 1 >
Event is triggered and new row is created which will include the new value in Column 1 >
Column 2 is recalculated based on changes in Column 1 >
Event is triggered and new row is created which will include the new value in Column 1 and Column 2 >
Column 3 is recalculated based on changes on either of the previously mentioned columns >
Event is triggered and new row is created which will include new value in Column 1, Column 2 and Column 3.
What I want to achieve is to have 1 row which will have all the new values, no need to generate any other rows but one which includes the changes from the user action and any recalculations based on that.