Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i hav 2 forms Form1 n Form2.i called form2 from the form1 thru a button which is in form1. Using the following code form2 opens but form1 is still visible.


Form2().ShowDialog();
Form2().Activate();
Form1().Close();

i want only form2 to be visible .how can i hide form1 when form2 is active?pls help..

--------------------------------------------------------------------------

@Mohammad Elsheimy if i include Form2().Show() instead of Form2().ShowDialog()form1 opens but form2 opens jus for a fraction of second.i want that when i run my application form2 should open when i click to a button in form1 and form1 should be invisible.
Posted
Updated 2-Apr-10 17:58pm
v2

1 solution

Your application won't get to the 2nd line:
Form2().Activate();
until it completes the first ShowDialog().

ShowDialog function blocks your code until the form closes

you should change it to
Form2().Show();
 
Share this answer
 

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