views:

16

answers:

2

When changing the project from console to windows app, I still am not able to use the namespace System.Windows.Forms. Do I really need to create a whole new project? If there is a better way, please give a detailed description of how to do this in visual studio step by step, thanks :)

+4  A: 

The Console Application project template that you started with does not have the necessary assembly references. Project + Add Reference and select System.Drawing and System.Windows.Forms.

Also be sure to make the necessary changes in the Program class. Main() must have the [STAThread] attribute and you need to add the boilerplate code to enable visual styles and start the message loop. Take a look at a sample Windows Forms project to get that right.

Hans Passant
+1  A: 

You can use Windows.Forms independent of the the type of project. All you need is a reference to it. In your solution explorer you will find a folder "References" just under your project folder.

Right-click and choose "Add Reference". Scroll through the list and add System.Windows.Forms (and probably System.Drawing).