Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have three windows forms, i have a button in the form 1 and a button in the form2,
if form1 button is clicked, then it shows the form2 as
form2 f2 = new form2();
f2.show();

and the form1 is still in the background and visible,
and there is one more button on the form2 when that button is clicked the same event happen that form2 is running in background and form3 shows up,
and now when the form3 is shown i want to hide the form1
how can i do that?
is there any property that can help me to know which form is running in behind.
Posted

The best way is for you to create an event in Form2 which Form1 handles. When Form2 shows Form3, it signals the event to Form1 which hides itself.

You would also have to provide an event for Form1 to redisplay itself, clearly!
 
Share this answer
 
Comments
CHill60 18-Dec-12 9:48am    
@OriginalGriff - sorry I should have refreshed my screen and spotted your answer
sariqkhan 18-Dec-12 9:55am    
i got it
Form1 f1 = (Form1)Application.OpenForms["Form1"];
f1.Hide();
 
Share this answer
 
Comments
sariqkhan 18-Dec-12 9:55am    
thank you too

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900