Reputation: 2645
Is it possible to run a windows form application with the console application?
And if so, how would i use the Main() void?
And how could i pass strings over from the windows form to the console?
Upvotes: 0
Views: 1591
Reputation: 434
First Create the windows Application like normally you do.
Create a new Console Application
In solution Explorer, goto References->Add Reference->Click Browse Tab->Select Project Path to Debug->Select the Application
Also add a Reference to System.Windows.Form;
In the code
Include the namespace of the Application using NewForm;// Example
class Program
{
static void Main(string[] args)
{
TestForm t = new TestForm(); //Class of WindowsFormApplication NewForm
t.ShowDialog();
}
}
}
Upvotes: 1
Reputation: 116
I think that what you are saying is that you want to have a console application that can simply open a form. You can do this.
Create your console application as per normal but then add your form to your project (or a reference to a project that contains the form). Then you just want something like this.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("I'm going to open a form now!");
var form = new Form1();
form.ShowDialog();
}
}
}
If you want to add information to your form, you could add properties to the form or a add a custom constructor which takes string information you want sent to the form.
Upvotes: 1