Reputation: 165
I am working on console application , I have currently created a windows form (name:Fcon) in my project , are there any possible ways to display fcon from console ?
Upvotes: 1
Views: 3770
Reputation: 165
i have found other solution
testform tf = new testform();
tf.Show();
just created forms object in main
Upvotes: 0
Reputation: 236
The easiest option is to start a windows forms project, then change the output-type to Console Application. Alternatively, just add a reference to System.Windows.Forms.dll, and start coding:
using System.Windows.Forms;
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.Run(new Form()); // or whatever
}
The important bit is the [STAThread] on your Main() method, required for full COM support.
Another way :
using System.Runtime.InteropServices;
private void Form1_Load(object sender, EventArgs e)
{
AllocConsole();
}
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
If you research this topic , just on Google you can find so much way to implement your question : my suggest is to try some method and verify what is more adapt to you.
Upvotes: 3