When my program runs it closes form1 after a few seconds. Depending on what happened during form1's lifespan I may want to open for开发者_运维百科m2. Normally I would just make a new instance of form2 and use the show() method. But form2 is then a child of form1 and then also closes. Does any body have an idea on how to get this to work? thanks.
in the properties of the project make sure to select "When last form closes" in the shutdown mode dropdown
Before you close form1 set form2.Owner property to Nothing. This will need to be done before the FormClosing event of form1, since form2 will already be scheduled for closing by then.
But this only works if form2 actually is a child of form1.
try looking for the MVC or MPV patterns. This is than best done in the controller or presenter and will not give you the problems that you describe.
精彩评论