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.
go to project > add existing item select the form myform. cs file and then click on the add button. This will import the file in your project. Save this answer.
Add a new form In Visual Studio, find the Project Explorer pane. Right-click on the project and choose Add > Form (Windows Forms). In the Name box, type a name for your form, such as MyNewForm. Visual Studio will provide a default and unique name that you may use.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With