I HAVE TWO WINDOWS FORMS AND I WANT TO OPEN THEM ONE AFTER THE OTHER

Goti Bandu

Total Post:119

Points:835
Posted by  Goti Bandu
C# 
C#
 902  View(s)
Ratings:
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. Sumit Kesarwani

    Post:378

    Points:2694
    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;

          newForm.show();

    }

    Hope that helps 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!