Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have a bool application setting and 2 forms, the first is a introduction form that I want to show and change the value of the setting to false then close itself and show the other form. When I launch a new instance of the application it should bypass the introduction form and go straight to the second one because it has looked at the setting which is now false so it will not load it again. How would I do this? I want the application to run with no forms open and check the setting. If it is true then the introduction form shows and sets the setting to false. If it is false is should show the second form only. It would need to go in 'Program.cs' where the application starts. Wrote this is a hurry so hope it makes sense. Thanks for any help.
Posted
Updated 18-Aug-13 12:54pm
v3
Comments
Sergey Alexandrovich Kryukov 18-Aug-13 18:49pm    
What does it mean, "run a form"? http://whathaveyoutried.com?
—SA
Henry Hunt 18-Aug-13 18:52pm    
Oh I mean open or show it
Henry Hunt 18-Aug-13 19:01pm    
I've tried doing 'Application.Run()' and then doing an if statement to check of the setting is true or false and telling it to show the first form if it is true and the second if it is false but that didn't work.
Sergey Alexandrovich Kryukov 18-Aug-13 19:45pm    
Look, stop wasting time in writing in a hurry. Write in 10 times slower and step by step, in sufficient detail. You are close to explaining it, but I don't want to pull information from you. You are more interested, so please, explain carefully.

—SA
Henry Hunt 19-Aug-13 5:22am    
I have just solved it myself with

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (Properties.Settings.Default.FirstRun == true)
{
APIKey APIKey = new APIKey();
Application.Run(APIKey);
}
else
{
MAIN_WeatherWatcher MAIN_WeatherWatcher = new MAIN_WeatherWatcher();
Application.Run(MAIN_WeatherWatcher);
}

1 solution

Yes, this is a well-know technique. However, I would advise another option: have only one form with two different set of controls, say, two panels with different set of controls. On first step, show one panel, have another one hidden. On second step, swap the visibility of panel. No two application runs, no closing of the form, no hidden surprises.

—SA
 
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