Home > DeveloperSection > Forums > I have two windows forms and I want to open them one after the other
Goti Bandu

Total Post:119

Points:835
Posted on    September-04-2013 1:45 AM

 C# C# 
Ratings:


 1 Reply(s)
 657  View(s)
Rate this:

My MainForm opens fine but I cant figure out how to get the second form to open. I read somewhere that I can only have one open at a time? In any case I want the second form to open first and then my mainform to open afterwards.

The issue I'm running into is, that InitializeComponent(); can't be accessed by any form other than the one that its attached to (as far as I've been able to find out).

Any ideas on what I'm supposed to do would be great as I'm still in the learning phase and my searching skills haven't turned up anything of use.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-04-2013 3:32 AM

Hi Goti,

When you run you application, as you may already know, main() is the entry point for your application. In your main() you will be able to find the following code which initialize and show which form should be loaded first.

Application.Run(new Form1());

In this case the Form1 is loaded and shown. If you want to show your 2nd form as soon as Form1 is loaded, You can put the following code in your Form1_Load -

private void Form1_load(object send, EventArgs e)

{

      Form2 newForm = new Form2;

      newForm.show();

}

Hope that helps 


Don't want to miss updates? Please click the below button!

Follow MindStick