In form1 , it has a button which call the method to create a form2. i want to create form 2 and then close form 1 immediately, but when i close form1 , form 2 was closed also, please help.
i use .net compact framework 2.0 and mobile 5.0
thank you very much
void clickbutton()
{
form2 f2 = new form2();
f2.show();
this.close();
}

Form Creation
Nagaraj K
write "this.close();" before "f2.show(); ".
Whoisit
The form you're closing is not the application's main form (the one in Application.Run()), right If it is, that would close the entire application. You can hide it instead of closing. Also, here’s a good rule to follow: never close a form which holds other forms in it.
For example:
Should not close Form2 unless Form3 is closed, and Form1 unless Form2 and Form3 closed:
Form1-Form2-Form3
Should not close Form1 till Form2 and Form 3 are closed. But can close Form2 and Form3 at any time:
Form2
Form1/
\
Form3
vivian20060829
private void button1_click(object sender, EventArgs e)
{
Form2 f2= new form2(1,66222);
this.close();
f2.show();
}
Seppe001
Thank you for your answer. But the problem still exist
private void button1_Click(object sender, EventArgs e)
{
this.Close();
Form2 = new form2(1, 66222);
Form2.Show();
}
form1 and form 2 close.
please help . thx