I created 3 different (but sharing same database connection) Windows Forms applications. Each such application is very simple and consists of a single form only.
Assuming I have 3 forms: Form1, Form2 and Form3, I now want to define Form1 is the main form (and only application), and invoke Form2 and Form3 from within Form1, as part of the Form1 application, not as independent applications. Something similar to:
private void btnForm2_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
private void btnForm3_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
form3.Show();
}
While that seems simple, I am confused as to how to import Form2 and Form3 to the Form1 project without compromising the integrity of what VS 2010 already did “automagically”.
That is, I believe that it’s not only the Form2.cs file that I need to drag and drop into the Form1 project, but other files as well, such as Form2.Designer.cs, Form2.resx and… more?
Do I need to copy the files under the project’s Properties and References too?
What are the steps required to methodically convert the three projects into one?
From your solution “Form1” you can import other project into it.
(Right-Click on solution: Add > Existing Project)
So now you will have:
You will have to setup the build order and the build dependency between projects.
Another way to do it, is to manually copy the files from one project to the other and add them to your project. And yes, you need all the files that VS created. (resx, .Designer.cs, etc) Just copy and drop the whole package in a folder of your project.
And no, you don’t need to touch Properties or Reference, unless one of the two other project had different references. It should be easy to track, because the file you copy will have error in the “using xxx” part of the files. You just need to add the correct references.
(Right-Click on project: Add > Existing Items)
Since your project doesn’t look huge, I would go with solution two.