vb.net 在表格 1 之前显示表格 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21398151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 16:36:17  来源:igfitidea点击:

Showing form 2 before form 1

vb.netwinforms

提问by TheNewbie

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

我有我在 Windows Visual Studio 2010 中编写的这个 VB.NET 程序,有两种形式。该form1会第一次去之前form2,但现在我改变了主意,我想form2,当我开过我的程序先加载form1。我已经尝试了很多故障排除,但form1仍然没有运气首先加载。

回答by ElectricRouge

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

在解决方案资源管理器中双击我的项目。在那里您可以将启动表单设置为 form2。

回答by Dom Sinclair

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

听起来好像您有一个简单的 windows 窗体项目,它没有子主程序(您应该阅读有关子主程序的信息,因为您可以遵循问题下方评论中的建议)。

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.

对于您的问题,您需要在解决方案资源管理器中单击“我的项目”,然后打开(如果默认情况下未打开)应用程序选项卡。选项卡左侧有三个下拉控件,最后一个是“启动对象”。在此之下,您会找到“Form2”。选择它,您的申请将从表格 2 而不是表格 1 开始。

回答by Suhas

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!

希望这可以帮助!

回答by Sunday Udegbu

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:

  1. 单击 form1,转到其 Topmost 属性并将其设置为 false。

  2. 单击 form2,转到其 Topmost 属性并将其设置为 true。

  3. 双击form1并编写以下代码:

   me.hide()
   form2.show()
  1. Double click on form2 and write the following code:
  1. 双击form2并编写以下代码:
   me.show()
   form1.hide()

I have tried and it worked.

我试过了,它奏效了。