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?
我经常从一个简单的控制台应用程序开始尝试一个想法,然后创建一个新的基于GUI的项目并复制代码。有更好的方法吗?我可以轻松转换现有控制台应用程序吗?
2 个解决方案
#1
65
Just add a new Winform, add the following code to your Main:
只需添加一个新的Winform,将以下代码添加到您的Main:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Then right click your project and select properties and change the "Output type" to Windows application and you're done.
然后右键单击您的项目并选择属性并将“输出类型”更改为Windows应用程序,您就完成了。
EDIT :
编辑:
In VS2008 the property to change is Application type
在VS2008中,要更改的属性是应用程序类型
#2
17
For completeness - and for other newbs like me - you also need to add:
为了完整 - 以及像我这样的其他新手 - 您还需要添加:
using System.Windows.Forms;
使用System.Windows.Forms;
... to the top of Program.cs
...到Program.cs的顶部
#1
65
Just add a new Winform, add the following code to your Main:
只需添加一个新的Winform,将以下代码添加到您的Main:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Then right click your project and select properties and change the "Output type" to Windows application and you're done.
然后右键单击您的项目并选择属性并将“输出类型”更改为Windows应用程序,您就完成了。
EDIT :
编辑:
In VS2008 the property to change is Application type
在VS2008中,要更改的属性是应用程序类型
#2
17
For completeness - and for other newbs like me - you also need to add:
为了完整 - 以及像我这样的其他新手 - 您还需要添加:
using System.Windows.Forms;
使用System.Windows.Forms;
... to the top of Program.cs
...到Program.cs的顶部