I have two windows forms and I want to open them one after the other

Total Post:119


 1226  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.

  1. Re: I have two windows forms and I want to open them one after the other

    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;

    Hope that helps 

      Modified On Mar-31-2018 12:37:20 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.