Hi,
I have a form where I "catch" if the user made any changes. If they try to move to another record without saving, I ask them if they want to save or not. If NOT, I would like the changed data NOT TO BE SAVED! But IT IS!
Here's the code...
Private Sub Check_if_record_modified(ByRef result As DialogResult, ByVal Action As String)
Me.ItemsBindingSource.EndEdit()
If (Me.SignsDataSet.HasChanges = True ) Then
result = MessageBox.Show("Do you want to save these modifications before moving to another record ", "Warning: Data Modified.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3)
If (result = Windows.Forms.DialogResult.Yes) Then
SaveChanges("All")
ElseIf (result = Windows.Forms.DialogResult.No) Then
Me.ItemsBindingSource.CancelEdit()
End If
End If
It appears that either the CancelEdit does not work.
I thought it might be due to the EndEdit that applies the changes but I need the EndEdit for the HasChanges to return True.
Beside, EndEdit should not save the information...
Thanks for your help!
Claude.

How-to cancel changes to a record on user request...
Simon Ellis
Yes, it looks like it works.
One more question:
If the user move to another record, I ask if he/she wants to save the modifications to the current record. They can reply Yes, No or Cancel.
If the pick Cancel, I would like to stay on the CURRENT record and CANCEL the move to the NEXT record.
Any idea
Thanks again,
Claude.
Andrew Kinloch
you can use the dataGridView.CurrentCell property to get or set the currently active cell.
or you could use the Rows(Index).Selected = true
bola shokry
EndEdit does save changes - it ends the editing process and commits changes
CancelEdit cancels the editing mode for the currently selected cell.
you should reject the changes:
Me.SignsDataSet.RejectChanges()
does this help/work for you