Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call windows form event?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00768888
Message ID:
00769034
Vues:
19
Hi Cathi,

Well I did that but it didn't work, but when I checked your code I see it didn't work because I was using the OnClose: (from the Overrides menu??)
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
...
...
End Sub
While i should use the form cosing event!!

Thanks Cathi.



>Hi Ahmad,
>
>You do use the form's Closing event but just set the Cancel property to True. Here is some sample code:
>
>
>Private Sub Form1_Closing(ByVal sender As Object, _
>    ByVal e As System.ComponentModel.CancelEventArgs) _
>    Handles MyBase.Closing
>  If (MessageBox.Show("Are you sure to close the application?", _
>    "My Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
>         MessageBoxDefaultButton.Button2) = DialogResult.No) Then
>       e.Cancel = True
>  End If
>End Sub
>
>
>
>>Thank you Ron,
>>
>>But what about the "X" control on the top right of rhe form (the close button), is there any handeler for it.
>>I tryed to use these propireties of the form (OnClosed & OnClosing) it's okey but assume I need to ask the user to confirm closing the form by displaying a Messagebox.show ("Are you sure you want to exit?"), ........
>>message if the answer is "No" simply I can say Exit Sub, that if I am using the btnExit sub.
>>
>>But if the user cliks on the "X" button any code I but in the (OnClosed & OnClosing) to cancel the exit action will fail.
>>
>>any idea?
>>
>>
>>
>>>Ahmad,
>>>You need to call the PerformClick method to raise a button's click event, as in:
>>>
>>>btnExit.PerformClick()
>>>
>>>In the example you had, you might also consider using the ButtonCancel property for the form, so when they press escape it calls the button's click method, as in:
>>>
>>>Me.CancelButton = btnExit
>>>
>>>Ron
<><><><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><><><>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform