How do you add an existing form to a new project?

后端 未结 21 2171
予麋鹿
予麋鹿 2020-12-13 09:06

I have never been able to successfully add a Form from an existing file to a new project.

I read on a blog that you add just the *.cs file and the depen

21条回答
  •  遥遥无期
    2020-12-13 09:36

    Maybe it is because of using visual studio 2012, but all these solutions didn't work. AtConway gave a hint to edit the csproj file. And that hint worked.

    1. Open the solution with the project that you want to add your three files.
    2. Let's assume you want to add MyForm.cs / MyForm.Designer.cs and MyForm.resX. Make sure they are in the folder of your project
    3. Add a dummy form (or usercontrol) with a dummy name: MyTempForm.
    4. Save the solution and close it in Developer Studio
    5. In a windows explorer delete the three MyTempForm files
    6. Rename your three MyForm files in MyTempForm, with the same extensions.
    7. Open your solution again in Developer Studio 2012
    8. See that your MyForm is now fully available as MyTempForm
    9. In the solution explorer rename MyTempForm back to MyForm

提交回复
热议问题