Click here to Skip to main content
13,056,401 members (115,490 online)
Rate this:
Please Sign up or sign in to vote.
I have a program that is nearly completed and written as a C# Console application. I do this because this program works with directories a lot and I am most comfortable writing console applications.

What I need is a way to have a popup form launched from my console application. The form doesnt need to do anything other than display some graphics generated by the console app.

I have looked at other people handel this problem by converting their entire project to a windows form application. I really dont want to do this as all i need a form for is a popup window with a graph displayed on it.

Is this even possible? And can someone either explain how to get this started or point me in the direction of an article that explains this.

Thank You,
Posted 19-Jan-12 6:19am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Nothing will work unless you eventually run System.Windows.Forms.Application.Run [EDIT] or, alternatively, System.Windows.Forms.Form.ShowDialog [END EDIT].

This is where the main cycle of a Forms application is executed; and this is something which I would call Forms application anyway. No need to argue over terminology; what I just told you the essence of thing.

Let me tell you that your "I don't want" needs some motivation which you did not provide. There is nothing wrong with Forms application; and you can keep your console code if you want, so from any practical point of view, you won't have any problem.

Now, don't be confused by the term "Console Application" as the application type. It is not alternative to "Windows Application". Simply put, "Windows Application" simply says: "hide the console", nothing else. If does not even have to have a Window or a Form (!). That said, make it a "Console Application", but with the forms. One practical way of doing it is this: 1) create a new Forms application; 2) change application type to "Console Application"; try it: it will run as a Forms application but will show a console; 3) move you console code to the application.

After your do it, you can modify your entry point method (which is usually "Main") to start with Console code, run System.Windows.Forms.Application.Run(Form) with you form later or on some condition, or whatever you like.

This way, you have a mixture of Console and Forms application, and no problems.

Tarakeshwar Reddy 19-Jan-12 18:09pm
*bows* As usual sir you have proved why are you the best in answering questions. I got to learn a lot from you.
SAKryukov 19-Jan-12 18:42pm
Thank you very much, Tarakeshwar.
Orcun Iyigun 19-Jan-12 19:05pm
Respect :) I totally agree with you.
SAKryukov 19-Jan-12 21:00pm
Thank you, Orcun.
Abey Thomas 19-Jan-12 20:34pm
Great answer!
SAKryukov 19-Jan-12 21:00pm
Thank you, Abey.
mjbohn 20-Jan-12 1:10am
Great! Again I learned from you
SAKryukov 20-Jan-12 2:20am
Thank you very much.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You would need to reference the System.Windows.Forms.dll and you can create a Form object and add the necessary controls to it.
SAKryukov 19-Jan-12 17:21pm
Incomplete -- can only confuse OP at the attempt to implement it. Please see my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170728.5 | Last Updated 19 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100