c# - how to run a winform from console application? -


How can I create, execute and control a winform from within a console application?

The easiest option is to start a Windows project, then change the output-type to a console application. Alternatively, just add a reference to System.Windows.Forms.dll, and start coding:

  Using the system. Windows.Forms; [STAThread] Fixed Zero Main () {Application.EnableVisualStyles (); Application.Run (new form ()); // or whatever)  

Important bit [your main () method on [STAThread] , required for full COM support is .


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -