[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Which event fires when a user clicks the X to close a window...

In vb there was the unlaod event what is the equal to that in vb.net, i want to check before i despose the
window if there is any pendeng changes which need to be saved..

 
0
AlexPonnath
Asked:
AlexPonnath
1 Solution
 
richard_robinsonCommented:
You could try Form.Closing
0
 
AlexPonnathAuthor Commented:
but how do i cancel the closing once it hits the closing event ???

lets say i want to ask the customer if he is sure he doesnt want to save the data, if he says he wants to save the data before
how can i tell the form to abort the close..
0
 
TorrwinCommented:
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        <execute your code>
    End Sub
0
 
Erick37Commented:
"The Closing event occurs as the form is being closed. When a form is closed, all resources created within the object are released and the form is disposed. If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true."

ex:

Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        If (MessageBox.Show("Do you want to exit?", "My Application", _
         MessageBoxButtons.YesNo) = DialogResult.No) Then
            e.Cancel = True
        End If

    End Sub

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now