简体   繁体   中英

How to setup the starting form of a winforms project in Visual Studio 2010

Does anybody know how to setup the starting form of a winforms project in Visual Studio 2010? I have ridden to go to Project Properties and change Startup Object, but in dowpdownlist the only options available were "(None)" and "ProjectName.Program.cs". The "program.cs" is my default code file. Please help me. (Im working in C#)

In your Program.cs, there is line like:

Application.Run(new Form1());

where you can substitute the form you'd like to start. If you change Form1 to another Form class, your project will start with that one.

在visual studio的菜单栏上:项目>项目属性>启动表单:选择要在启动时运行的项目中的表单。

It is not only in Program.cs. It is in any class where exists a "static Main()" function. Programs.cs is made for you by the IDE on certain type of project. It's not a must.

Example:

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.DoEvents();
        Application.Run(new Form2());
    }

The project properties, tab: "Application" show a dropdown with every class that as a static Main() function. You could choose the one you want from there.

Go to 'Tools' and click on 'Options'.

Next, go on the 'Startup' option within the 'Environment' category, and select 'Show Start Page' from the drop down menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM