如何使用visual studio 2005在c#.net iam中设置启动表单 [英] How to set up startup form in c#.net iam using visual studio 2005

查看:66
本文介绍了如何使用visual studio 2005在c#.net iam中设置启动表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚从VB切换到C#并正在编写Windows应用程序。在VB中,您可以通过选择项目的属性并移动到下拉列表来轻松更改启动表单,您可以在其中选择要用作启动的表单。我看不到C#中的等价物。也就是说,有一个Startup Object下拉列表,但它只列出了ProjectName.Project文件。

I have just switched from VB to C# and am writing a Windows application. In VB you could easily change the startup form by selecting the properties of the project and moving to a dropdown where you could pick the form you want to use as the startup. I see no equivalent in C#. That is, there is a Startup Object dropdown, but it only lists the ProjectName.Project file.

推荐答案

你可以继续使用Program.cs文件,这里是Main()显示运行表单构造函数更改另一个表单构造函数的方法



You can go on Program.cs file and here Main() method showing where your running form constructor is to change another form constructor

Application.Run(new Form1());





用新的表单构造函数更改Form1()



to change Form1() with your new form constructor


您无法在C#中的任何工具箱中设置启动表单。相反,您必须在Main方法中实例化该表单。这是一个通常位于 Program.cs 中的片段。只需实例化你想要在启动时运行的表单而不是 form1



You cannot set the startup form from any toolbox in C#. instead you will have to instantiate that form in the Main method. Here is a snippet that ususally lies in Program.cs. Just instantiate the form you want to run on startup instead of form1.

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }


请参考: MSDN:如何:在Windows应用程序中选择启动表单 [ ^ ]


这篇关于如何使用visual studio 2005在c#.net iam中设置启动表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆