You don't want to close Form1: if you do, your application will end, and both form1 and form2 will close.
You need to go back to your course notes, and read up on instances:
form1 obj1=new form1()
form1.close()
There are a number of problems here:
1) obj1 does not refer to the existing form1 you are displaying. When you wrote the
new
keyword it is supposed to remind you taht it is creating a new instance of form1. You now have two instances: the running one which you can see, and the new one you just created, which you can't.
2)
form1.Close
doesn't exist as standard. It would be a static method (don't worry about the name, you will find out later) which is not connected to any instance, and so cannot close the current (or indeed any) form.
What you want is
this
this
is the word you use when you want to explicitly refer to the current instance of a class. So, you could use:
this.Close();
And teh current instance of Form1 would close. Unfortunately, this will also end your application.
Replace your code with:
this.Hide();
form2 f2 = new form2();
f2.ShowDialog();
this.Show();
And you Form1 will appear to close, form2 will appear, and when it closes, for1 will reappear.
OK?