trying to add an existing Windows form into a VS2012 WinForm project, I go "Add/Existing item..." then import: MyForm.cs, MyForm.designer.cs, MyForm.resx
This used to work in earlier versions of VS. (I may have to adjust the namespaces.)
In VS2012 MyForm.designer.cs and MyForm.resx are now not associated with the Form for purposes of the Designer; i.e. they show up as separate file entries in the Solution Explorer, not nested under MyForm. Double-clicking MyForm shows an empty form (no controls) with no error messages. The project compiles and runs OK.
However, when I drag and drop the same files into the project (adjust/rename the namespace), the form files are properly associated with one another and the Designer opens the form fine.
While I now have a solution, can someone highlight what difference is between these approaches, what is the point of having an Add/Existing Item option if it doesn't work, and what is actually going on when dragging the files? Which file (.csproj perhaps?) is responsible for joining the form files? Because it works both ways in earlier versions of VS can I assume this is a bug?
Thanks.
Tried to reproduce your issue - without success.
Assume that you want to import a Form called YourFormName
. Then you should only add YourFormName.cs
to the project - the rest parts (YourFormName.designer.cs
and YourFormName.resx
) will be added automatically.
My steps: