简体   繁体   English

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

[英]How to change a console application to a windows form application?

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. 我一直在开发一个控制台应用程序,直到我们的项目需要一个花哨的UI来使用它,所以我们决定将项目类型更改为Windows窗体应用程序。 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? 那么还有更优雅的方法吗?

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.” 然后,在“应用程序”选项卡下,将项目的“输出类型”从“控制台应用程序”更改为“Windows应用程序”。

项目类型需要设置为Winexe (取决于IDE,也称为Windows应用程序 ),而不是项目属性中的Exe (取决于IDE,也称为控制台应用程序 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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