How do I set the default form in vb.Net?
How do I set form number four as the default f开发者_StackOverflow中文版orm that will run when I press on f5 in visual studio 2008. Because form 1 will always be the first to start
- Right-click on your project in solution explorer.
- Choose properties.
- Select the Application Tab.
- Select your form from the dropdown under 'startup form'
In the Project Properties, there's a field called "Startup form" - select your form in there.
- Right-click your Project within the Solution Explorer.
- Choose Properties.
- Select the Web tab on the left-hand side.
- Under the Start Page section, define the Specific Page you would like to default to when the application is launched. Save your changes.
Right-click your Project within the Solution Explorer. Choose Properties. Select the Web tab on the left-hand side. Under the Start Page section, define the Specific Page you would like to default to when the application is launched. Save your changes.
The other solutions work, but they will disable the use of ApplicationEvents
like Startup
, because the startup object has to be Sub Main
for those to work.
To change the form started by Sub Main
, do the following:
- Close your project in Visual Studio.
- Open your project's folder in explorer.
- In it, open folder
My Project
. - Open
Application.myapp
with any text editor. - Change the form between the
<MainForm>
tags to your (new) main forms name. - Save and close.
- Open
ApplicationDesigner.vb
with any text editor. - Find the following line and change YourMainFormsName to your (new) main forms name:
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.YourProjectsName.YourMainFormsName
End Sub
- Save and close.
- Open your project again and start it up. The startup form should have changed.
In my case, it doesn't work immediately from project properties. I have to close the solution and re-open it in order to see the latest form you have created and if you intend to make a startup object.
精彩评论