Click here to Skip to main content
15,898,665 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI, i am currently developing an application using visual c# and it consists of 2 forms, the first form is just the introduction form that accepts user input. after the user has typed in their input and clicks the start button,the current form is supposed to close and the second one opens but i just cant get the coding right.
please help with sample codes..
Posted

If I understood correctly, in your Main method (where you're starting your application), first create an instance of your first form, show it as dialog and after that run the second form.

Something like:
C#
static void Main() {
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);
   if (new IntroductionForm().ShowDialog() == DialogResult.OK) {
      Application.Run(new MainForm());
   }
...
 
Share this answer
 
use Form.Close[^] to close your introduction form when the user clicks your button.
 
Share this answer
 
Comments
Philippe Mori 3-Sep-11 12:09pm    
Well if the first form was the main application form, it is a bit more complex than that. Assuming that the second form is the main application, solution 2 would be correct.
Simon Bang Terkildsen 3-Sep-11 12:36pm    
Yeah well the question is not very clear and the answer I provided was the answer to the question the way I understood it.
That said I agree Mika's answer is better :) That what so nice; an inquirer doesn't have to settle for only one answer ;)
morojele 3-Sep-11 12:43pm    
Philippe Mori thanks for the tip but im quite new in to the programming field,i tried using ur option but what does this"[^]" mean? what does it do? its been giving me problems. thanks again
Philippe Mori 3-Sep-11 12:52pm    
[^] is just a link that open in a new Windows (for documentation on Form.Close). By the way, original answer is from Simon.

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