问题描述
我经常从一个简单的控制台应用程序开始尝试一个想法,然后创建一个新的基于 GUI 的项目并复制代码.有没有更好的方法?我可以轻松转换现有的控制台应用程序吗?
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,将以下代码添加到您的Main:
Just add a new Winform, add the following code to your Main:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
另外,请确保 [STAThread] 属性在您的 Main 函数上方声明,以指示您的 Windows 应用程序将使用的 COM 线程模型(更多关于 STAThread 这里).
Also, be sure the [STAThread] attribute is declared above your Main function to indicate the COM threading model your Windows application will use (more about STAThread here).
然后右键单击您的项目并选择属性并将输出类型"更改为 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
这篇关于如何将 .NET 控制台应用程序转换为 Winforms 或 WPF 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)