What is the best way to copy or cut/past a form from one Project to another Project within a Solution in Visual Studio?
Whenever I try it, using the solution explorer (drag and drop or right clicking cut and past), it only copies the underlying C# code and not the necessary 'bits and pieces' that help you visualise the form via the form designer.
Figured it out - knew it would be something daft.
Apparently the target project should have the references:
included within the project FIRST before you do any copy or pasting or else you will get the problem I described.
Thanks for anyone who tried to help BTW.
It's way easier now in 2012. Just go to File > Add > Existing Project > Drag and drop the form into the project that you want to add it to.
I am using Visual Studio 2010, below are the steps I performed:
To copy a form from one VS2013 project to another, the easiest, (fewest mouse clicks) is:
In your target project, right mouse click on your parent folder (likely your project) and in the menu select, "Add; Existing Item".
Then select the form's cs file in your source project. For example select Form.cs (not the Form.Designer.cs or Form.resx).
Open Form.cs in your target project and change the namespace (all instances).
Close and reopen Form.cs and you will see all the controls, etc.
If you want to forms in same machine then simply you can do this.
In Solution Explorer Project --> Add --> Add Existing Item.
Select only .cs
(Sample.cs)
file from source directory and Refresh the current solution Explorer it will Work.** This one works for me:
1) Copy the source files (.cs or vb, .designer, .resx) into target folder
2) Show hidden files in target solution
3) Select these files and include them into project.
This will add winform or any other partially divided files cleanly.