Jemuel Elimanco
Jemuel Elimanco

Reputation: 556

how to remain the form open when x button(in the upper right most) is clicked?

I'm having a problem with my form in VB.net. I want to remain my form open when I clicked no in the decision box.

this is my code:

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If (MsgBox("Do you want to quit now?", MsgBoxStyle.YesNo).ToString = "Yes") Then
            Dim login As New login
            login.Show()
        Else
            'remain my form
        End If
    End Sub

Please help me. thankyou.

Upvotes: 0

Views: 37

Answers (1)

Stijn
Stijn

Reputation: 2060

You should set the Cancel property of the e parameter to True.

e.Cancel = True

For more info, check the Form.FormClosing (or Form.Closing) event.

Upvotes: 1

Related Questions