开发者

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


  1. Right-click on your project in solution explorer.
  2. Choose properties.
  3. Select the Application Tab.
  4. 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.


  1. Right-click your Project within the Solution Explorer.
  2. Choose Properties.
  3. Select the Web tab on the left-hand side.
  4. Under the Start Page section, define the Specific Page you would like to default to when the application is launched. Save your changes.

How do I set the default form in vb.Net?


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:

  1. Close your project in Visual Studio.
  2. Open your project's folder in explorer.
  3. In it, open folder My Project.
  4. Open Application.myapp with any text editor.
  5. Change the form between the <MainForm> tags to your (new) main forms name.
  6. Save and close.
  7. Open ApplicationDesigner.vb with any text editor.
  8. Find the following line and change YourMainFormsName to your (new) main forms name:
Protected Overrides Sub OnCreateMainForm()
    Me.MainForm = Global.YourProjectsName.YourMainFormsName
End Sub
  1. Save and close.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜