Reputation: 121
Is there a way to change the command of the (x) Button?
I want to show another form and hide the current form instead of closing the program.
where should I put this? :
Me.Hide()
Form.Show()
I tried puttin it on the Form Closing/Closed Event, but nothing happen, am I missing something?
Upvotes: 0
Views: 1957
Reputation: 941635
Sure, the FormClosing event is made to do that. You'll need to pay attention to the reason the form is being closed, something like this:
Protected Overrides Sub OnFormClosing(ByVal e As FormClosingEventArgs)
MyBase.OnFormClosing(e)
If Not e.Cancel AndAlso e.CloseReason = CloseReason.UserClosing Then
e.Cancel = True
Dim frm = New Form2()
frm.Show()
Me.Hide()
End If
End Sub
Do note that you have to give a way for your user to terminate the app.
Upvotes: 2