Posted By

indra on 07/28/11


Tagged

validation Winform


Versions (?)

Cancel dialog result from closing form


 / Published in: VB.NET
 

  1. Me.DialogResult = Windows.Forms.DialogResult.None
  2.  
  3. 'sample usage
  4.  
  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  

You need to login to post a comment.