In Visual Studio 2013 when I add an existing form then controls don't appear on designer

1.2k views Asked by At

I'm working on a windows form application. I start a new project. I delete the Form1 stuff from the new project. I go and add from existing in the solution explorer and choose Form1.cs, Form1.Designer.cs, and Form1.resx from another project. When I look at the designer Form1 just looks blank, like a new one would with none of the controls appearing. The program still compiles fine with all it's controls intact. Did I miss a step somewhere? I've closed and reopened the project etc. This happens every single time repeatedly so I believe I'm missing something but searching here or the rest of the web hasn't provided me a solution. Maybe it's just assumed to be known by everyone already?

I am just learning c# and Visual Studio so hopefully I didn't miss something stupid. I was following direction for how to do this from a book. Some projects are re-used to teach a new idea so they have you start a new project and add in existing items from the original to then work on the new idea.

2

There are 2 answers

5
CurtisHx On

Make sure that you are loading the Form1 that you think you are loading.

By default, Visual Studio 2013 (on Windows 7) will create a folder in Documents (C:\Users*Your user name*\Documents) called "Projects". Whenever you create a new project from within Visual Studio by going to File->New Project, Visual Studio will (by default) create a new folder in the Projects folder with the project name.

I think when you "delete" Form1, you're not actually deleting it, just removing it from the project. When you go to add Form1, you're just selecting it from the same project folder, when you actually wanted to load it from a different project folder.

Try this: In your current project (the one where you deleted Form1 and then added it), in the Solution Explorer, right click on the project, and select "Open Folder in File Explorer".
enter image description here

This will open the project folder on disk. Now, delete Form1.cs from within Visual Studio, and switch back to the project folder. If Form1.cs is still in that project folder, then you just removed it from the project. The actual files still exist on disk. When adding existing items, Visual Studio will typically default to the selected project folder.

I have a very strong suspicion that the Form1 that you are really looking for resides in a different project folder. Without knowing the book or tutorial you are following, I can't give you any hints as to where the Form1 you want is located.

0
bilgehanuk On

In VS 2013 I chose "Add existing Item" and just selected the .cs files, don't add *.Designer.cs and *.resx files. Then waited for few minutes and restarted VS2013. Designer.cs and resx files appeared as associated with Forms but they were excluded. I right clicked them and chose "Include In Project". Then it worked fine.