Converting Console App to Winform app


M

Madalin Nicula

Hi
I have a console app which works fine and I want to convert it to a WinForm
app.Can anyone help me how to do it?
 
Ad

Advertisements

H

Herfried K. Wagner [MVP]

Madalin Nicula said:
I have a console app which works fine and I want to convert it to a
WinForm app.Can anyone help me how to do it?
You can change the project type in the project properties dialog.
 
Ad

Advertisements

T

Teis Draiby

You also need to inherit your class from the 'System.Windows.Forms.Form'
class which will automatically activate Form Designer support (very nice
detail).
Remember to add a reference to the System.Windows.Forms dll.

This is the minimum code for a Windows Application:

--- Code --------------------------------
using System;
using System.Windows.Forms;

namespace MyNamespace
{
class MyClass : System.Windows.Forms.Form
{
[STAThread]
static void Main()
{
Application.Run( new MyClass() );
}
}
}
------------------------------------------

(To show what you created in the Form Designer you need to call
InitializeComponent() from the class constructor)

good luck, Teis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top