|
-
Jul 29th, 2019, 09:04 AM
#1
Thread Starter
Lively Member
Edit before changing records
I know this is a old question so if you have seen the answer, just direct me to it. I have a form with a Datagridview for moving between records. I have a routine that checks to see if the user has made any unsaved changes. I ask them if they would like to save changes before leaving the current record. In the event they say yes and the validation fails how do I keep them on the current record so they can fix the errors before the record goes to whichever record they have selected from the data grid view. Basically cancel the move and let them fix the errors or cancel the update before changing records.
Last edited by wjburke2; Jul 29th, 2019 at 09:10 AM.
-
Jul 29th, 2019, 12:47 PM
#2
Re: Edit before changing records
If you want the ability to cancel exiting a row then the RowValidating event would work well.
Code:
Private Sub DataGridView1_RowValidating(sender As Object, e As DataGridViewCellCancelEventArgs) Handles DataGridView1.RowValidating
If MessageBox.Show("Save Changes?", "Save", MessageBoxButtons.YesNo) = DialogResult.No Then
e.Cancel = True
End If
End Sub
-
Jul 29th, 2019, 01:57 PM
#3
Thread Starter
Lively Member
Re: Edit before changing records
Thank you, Wes that worked. Don't know why I thought putting the code in the dgv RowLeave would work. Thanks again
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|