John Nuñez
John Nuñez

Reputation: 1830

How to close main form without closing child forms?

I have two forms named:

Form1 & Form2

In the Form1 I have a button with this code in the button click event:

Form2.Show()
Me.Dispose()

When I click this button, it close both forms at the same time.

I only need to close the Form1.

Upvotes: 1

Views: 591

Answers (2)

J...
J...

Reputation: 31393

Your project settings are probably set to terminate the application when the startup form closes. Changing the option to "last form closes" should fix this.

"Project" menu -> 'YourApp' Properties... -> Application Tab

find : "Shutdown Mode"

Change from "When startup form closes" --> "When last form closes"

Upvotes: 4

dwerner
dwerner

Reputation: 6602

Don't call Dispose yourself. Try Me.Close() in the same context.

Upvotes: 0

Related Questions