.netvb.netformswinformsapplication-framework

In a Windows Forms application, how to only close the first form?


I have a strange problem with a Windows Forms Application. I have multiple forms open, each one corresponding to a file. When I close the first one, all others are also closed and the program is exited. However, when closing one of the other forms, I do not experience such a behaviour.

Searching for this, I found this article on MSDN but it does not help me.

So, how do I do this right?


Solution

  • You need to change your Shutdown mode to When Last form closes instead of When Startup form closes

    You can find this setting in:

    Project properties>Application Tab>Windows Application framework properties>Shutdown mode

    These should be fairly self explanatory settings