Cancel form close

S

Sameh Ahmed

Hello there
IS there a way to cancel a form close after the user clicks on the close
button?
I want to confirm from the user the close operation and if he chooses not
to, I would cancel the operation
any ideas?
Regards
Sameh
 
J

Josip Habjan

Hi,

**
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim dlgres As DialogResult = _
MessageBox.Show("Are you shure you want to close this
widnow?", _
"MyApp", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If dlgres = DialogResult.No Then
e.Cancel = True
End If
End Sub
**

Regards,
Josip Habjan
URL: http://www.habjansoftware.com
 
A

Armin Zingler

Sameh Ahmed said:
Hello there
IS there a way to cancel a form close after the user clicks on the
close button?
I want to confirm from the user the close operation and if he
chooses not to, I would cancel the operation
any ideas?
Regards
Sameh


Catch the Closing event.

Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top