Meilleur auteur de réponses
fermer l'application avec confirmation

Question
-
Comment faire pour contrôler la fermeture d’une form en VBNET 9.je connu sa en vb6 :
Private Sub Form_Unload(Cancel As Integer)
Var = MsgBox("vous ete sur de fermer cette fenêtre", vbInformation + vbYesNo)
If Var = vbNo Then
Cancel = True
End If
End Sub
Mais en VBNET 2008 sa marche pas je fais un test sur Me.close sa marche pas.
Réponses
-
merci tous mond mais la repence et comme sa:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' message de confirmation
e.Cancel = True
End Sub- Marqué comme réponse Gabriel MongeonModerator lundi 6 avril 2009 16:57
Toutes les réponses
-
me.close() fonctionne
voici la classe générée par vb9 pour une aboutform
Public NotInheritable Class AboutBox1
Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Définissez le titre du formulaire.
Dim ApplicationTitle As String
If My.Application.Info.Title <> "" Then
ApplicationTitle = My.Application.Info.Title
Else
ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
Me.Text = String.Format("À propos de {0}", ApplicationTitle)
' Initialisez tout le texte affiché dans la boîte de dialogue À propos de.
' TODO : personnalisez les informations d'assembly de l'application dans le volet "Application" de la
' boîte de dialogue Propriétés du projet (sous le menu "Projet").
Me.LabelProductName.Text = My.Application.Info.ProductName
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
Me.LabelCopyright.Text = My.Application.Info.Copyright
Me.LabelCompanyName.Text = My.Application.Info.CompanyName
Me.TextBoxDescription.Text = My.Application.Info.Description
End Sub
Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
Me.Close()
End Sub
End Class
fred -
Bonjour,
voici un bout de code qui devrait répondre à votre attente, dans cet exemple dans la form j'ai abonné un bouton à l'événement click :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If MessageBox.Show("Etes vous sur de vouloir fermer l'application ?", "Fermer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then Me.Close() End If End Sub
En espérant avoir pu vous aider.
Audrey - http://blogs.developpeur.org/audrey/ -
merci tous mond mais la repence et comme sa:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' message de confirmation
e.Cancel = True
End Sub- Marqué comme réponse Gabriel MongeonModerator lundi 6 avril 2009 16:57
-
-