Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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?

like image 640
Kang Min Yoo Avatar asked Jun 18 '12 04:06

Kang Min Yoo


People also ask

How do I add a console application to Windows form?

You need to create a Windows application. Then right click the project and go to properties and set the Output Type for the application to Console Application. This will then not only show your form but also the Console Window. So now you can use the Console class to read in or display messages to that console Window.

What is the difference between Windows Forms application and console application?

A Windows form application is an application that has a graphical user interface(GUI) like the Visual C# IDE. A console program on the other hand is a text application. There are not fancy controls like buttons or textboxes in a console application and they are run from the command prompt.

How do I switch from console app to web app?

To convert this into a ASP.NET Web App, we need to do 3 things: Convert the console project into a web project (csproj) Introduce a Generic Host to host our Web App. Rewrite the Main method to run our WebHost.


1 Answers

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.”

like image 130
astro boy Avatar answered Oct 21 '22 18:10

astro boy