如何将控制台应用程序更改为Windows窗体应用程序?

如何将控制台应用程序更改为Windows窗体应用程序?

问题描述:

我一直在开发一个控制台应用程序,直到我们的项目需要一个花哨的UI去与它,所以我们决定更改为Windows窗体应用程序的项目类型。我们尝试将代码放在我们的入口点:

I had been developing a console application, until our project needed a fancy UI to go with it, so we decided to change the project type to windows form application. We tried putting the code below in our entry point:

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

这是一种工作,但原来的控制台窗口仍然存在。

It kind of works, but the original console window is still there.

我已经搜索了一些有用的信息,例如一个,但他们做的是在它创建后基本上杀了窗口,而不是解决问题的根本。

I've googled out some useful infos like this one, but what all they do is essentially killing the window after it has been created, not tackling the root of the problem. So is there any more elegant way to do this?

在解决方案资源管理器中右键单击项目并选择属性。
然后,在应用程序选项卡下,将项目的输出类型从控制台应用程序更改为Windows应用程序。

Right click your project in the solution explorer and select properties. Then, under the "Application" tab change the "Output type" of your project from "Console Application" to "Windows Application."