You must use the CellValueChangedEvent
and the CurrentCellDirtyStateChanged
events for this.
Private Sub dgv_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.CellValueChanged
Dim con1 As OleDbConnection = con
con1.Open()
Dim dt As New DataTable
Dim _command As OleDbCommand = New OleDbCommand()
_command.Connection = con1
_command.CommandText = "SELECT * FROM table_name WHERE " & likeContent & ""
dt.Load(_command.ExecuteReader)
Me.dgv.DataSource = dt
con1.Close()
End Sub
Private Sub dgv_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles dgv.CurrentCellDirtyStateChanged
If dgv.IsCurrentCellDirty Then
dgv.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
End Sub