C# 如何设置哪个表单先出现
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13553088/
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
How to set which of the forms appear first
提问by Tamar Cohen
I'm a beginner c# programmer, and i'm getting familiar with the Windows Forms App. I have 2 forms and i'm trying to understand how to set one of them to be the first one that appears when i'm running the application.
我是一名初级 c# 程序员,我正在熟悉 Windows 窗体应用程序。我有 2 个表单,我试图了解如何将其中一个设置为我运行应用程序时出现的第一个表单。
Is there a way to set this, or I have to create the forms by the order they appears?
有没有办法设置它,或者我必须按照它们出现的顺序创建表单?
采纳答案by SLaks
In Program.cs, you will see the following line of code
在 中Program.cs,您将看到以下代码行
Application.Run(new Form1());
This line shows Form1.
You can change it to do whatever you want.
此行显示Form1.
你可以改变它来做任何你想做的事。
回答by Frank59
Write in Program.cs
写入 Program.cs
Application.Run(new YourMainForm());
回答by Sohail
In your visual studi, when ever you open a project by default program.cs will open.
在你的可视化研究中,当你默认打开一个项目时 program.cs 就会打开。
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
you can see above Application.Run(new Form1());
你可以在上面看到 Application.Run(new Form1());
whatever your form name is type there, then whenever you are starting first this form will run
无论您的表单名称是什么,那么无论何时您首先开始此表单都会运行
回答by fakhir ali
In Program.cs, you will see the following line of code
在 Program.cs 中,您将看到以下代码行
Application.Run(new Form1()); This line shows Form1. You can change it to do whatever you want.
Application.Run(new Form1()); 此行显示 Form1。你可以改变它来做任何你想做的事。

