Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there a way to prevent a form from closing when the user clicks on the close button on the top right of the form. I plan to bring up a message box asking if they are sure they want to do this - I cant seem to find how to do it in VB.NET :(

 

Thanks.

Si

Posted

Excellent - Thanks for your quick reply :)

heres the code that I ended up using if anyone is intrested

 

 

Private Sub Account_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
       Dim CloseAnswer As Integer
       CloseAnswer = MsgBox("Are you sure you want to close this form?", MsgBoxStyle.YesNo)
       If CloseAnswer = 6 Then
           'the user wants to continue quitting
           'Me.Close()
       Else
           'the user has changed his/hers mind
           e.Cancel = True
       End If
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...