TheNewbie
TheNewbie

Reputation: 112

Showing form 2 before form 1

I have this VB.NET program that I wrote in Windows Visual Studio 2010 and there are two forms. The form1 will go first before form2 but now I changed my mind and I want form2 to load first when I open my program before form1. I have tried a lot of troubleshooting but no luck form1 is still loading first.

Upvotes: 0

Views: 11892

Answers (5)

donald
donald

Reputation: 1

Please navigate on solution Explorer and click program.cs then change Application.Run(new nameoftheformyouwanttostartwith());

on where its written name of the for you want to start it then enter then name

Upvotes: 0

Sunday Udegbu
Sunday Udegbu

Reputation: 1

The following steps may help out:

  1. Click on form1, go to its Topmost property and set it to false.

  2. Click on form2, go to its Topmost property and set it to true.

  3. Double click on form1 and write the following code:

   me.hide()
   form2.show()
  1. Double click on form2 and write the following code:
   me.show()
   form1.hide()

I have tried and it worked.

Upvotes: 0

Suhas Gosavi
Suhas Gosavi

Reputation: 2180

Go to the project menu and click " Properties" (the bottom option). In the tab that opens, change the drop down list labelled "Startup Form" to whichever form you want to show first.

Hope this helps!

Upvotes: 1

Dom Sinclair
Dom Sinclair

Reputation: 2528

It sounds as if you have a straightforward windows forms project that does not have a sub main procedure (you should read up about sub main procedures as with that you could follow the advice in the in the comment below your question).

For your problem you need to click on 'My Project' in the solution explorer and then open up (if it doesn't open by default) the application tab. There are three drop down controls on the left hand side of the tab the last of which is 'Startup Object'. Under this you will find 'Form2'. Select that and your application will start with form 2 rather than form 1.

Upvotes: 1

ElectricRouge
ElectricRouge

Reputation: 1279

Double click on My Project in Solution Explorer. There you can set the Startup form to form2.

Upvotes: 2

Related Questions