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
Dipa AhujaPosted May 26, 2010, 7:06 AM
form2 's FormClosed event:
Koteswararao MallisettiPosted May 26, 2010, 4:42 AM
i want separate process from here that is requirement of me
Jaish MathewsPosted May 21, 2010, 1:20 PM
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.