我要如何转换一个.NET控制台应用程序以一个WinForms或WPF应用程序应用程序、我要、控制台、WPF

2023-09-02 01:42:30 作者:独守空房丶为等伊人笑

我经常先从简单的控制台应用程序来尝试出了一个主意,然后创建一个新的基于GUI的项目,并复制code的影响。有没有更好的办法?我可以将我现有的控制台应用程序容易吗?

I frequently start with a simple console application to try out an idea, then create a new GUI based project and copy the code in. Is there a better way? Can I convert my existing console application easily?

推荐答案

只需添加一个新的WinForm的,添加以下code到主:

Just add a new Winform, add the following code to your Main:

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());

然后右键单击您的项目,并选择属性,然后更改输出型到Windows应用程序,你就大功告成了。

Then right click your project and select properties and change the "Output type" to Windows application and you're done.

编辑:

在VS2008的属性更改为应用程序类型

In VS2008 the property to change is Application type