Cancel dialog result from closing form

/ Published in: VB.NET
Save to your folder(s)

Copy this code and paste it in your HTML
  1. Me.DialogResult = Windows.Forms.DialogResult.None
  3. 'sample usage
  5. Try
  6. mybindingsource.EndEdit()
  7. en.SaveChanges()
  8. MessageBox.Show("Data successfully saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
  9. Catch ex As Exception
  10. If ex.InnerException.ToString.Contains("PRIMARY KEY") Then
  11. MessageBox.Show("Duplicate record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  12. Me.DialogResult = Windows.Forms.DialogResult.None
  13. End If
  14. End Try

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.