hai,
i have 2 forms names are form1,form2
with in the form1 in button click event i want open the new form that is form2 and form 2 is close.
for this i write
button1_click( object sender,eventargs e)
{ form2 f2=new form2();
form2.show();
this.close();
}
but here 2 forms will close that is the problem dont suggest hide() method
if you know any other way to open form2 tell to me.......
Loading

Jaish MathewsRank #225 · 11K reputationPosted May 21, 2010, 9:20 AM EDT
THis is expected behaviour. Beacuse you defined Form2 object inside Form1 i.e. Form2 object scope and life is within Form1 only.
So once Form1 closed all objects inside it will be released, including Form2 object. That's why Form2 is closing automatically.
In such scenarios you need to assign a single form, from which each form can be loaded. You can use MDI form for this purpose.
Here also once MDI form closed, all other forms will be closed automatically, it's expected behaviour.
Koteswararao MallisettiRank #2,740 · 511 reputationPosted May 26, 2010, 12:42 AM EDT
i want separate process from here that is requirement of me
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 26, 2010, 3:06 AM EDT
form2 's FormClosed event: